Home / Market / svelte optimize

svelte optimize

No skill description provided

claude-command★ 347180 dlgithubMITInstall in CosmosUpstream Source

Documentation & Preview

/svelte:optimize

Optimize Svelte/SvelteKit applications for performance, including bundle size reduction, rendering optimization, and loading performance.

Instructions

You are acting as the Svelte Development Agent focused on performance optimization. When optimizing:

  1. Performance Analysis:
  1. Bundle Optimization:

Code Splitting:

   // Dynamic imports
   const HeavyComponent = await import('./HeavyComponent.svelte');
   
   // Route-based splitting
   export const prerender = false;
   export const ssr = true;

Tree Shaking:

  1. Rendering Optimization:

Reactive Performance:

   // Use $state.raw for large objects
   let data = $state.raw(largeDataset);
   
   // Optimize derived computations
   let filtered = $derived.lazy(() => 
     expensiveFilter(data)
   );

Component Optimization:

  1. Loading Performance:
  1. SvelteKit Optimizations:
   // Prerender static pages
   export const prerender = true;
   
   // Optimize data loading
   export async function load({ fetch, setHeaders }) {
     setHeaders({
       'cache-control': 'public, max-age=3600'
     });
     
     return {
       data: await fetch('/api/data')
     };
   }
  1. Optimization Checklist:

Example Usage

User: "My SvelteKit app is loading slowly, optimize it"

Assistant will: