Svelte Optimize

Commandcommand1531Verified

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

Install CommandLocked
npx claude-code-templates@latest --skill ••••••••••••••••••••
Unlock to reveal command
ByCommunity
claude-code — commands svelte svelte optimize
$

Interactive Terminal Locked

Unlock this skill to run and inspect the interactive installation sequence.

CookApps Fine Software Cuisine
CONTENT

/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:

- Analyze bundle size with rollup-plugin-visualizer

- Profile component rendering

- Measure Core Web Vitals

- Identify performance bottlenecks

- Check network waterfall

2
Bundle Optimization:

Code Splitting:

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

Tree Shaking:

- Remove unused imports

- Optimize library imports

- Use production builds

- Eliminate dead code

3
Rendering Optimization:

Reactive Performance:

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

Component Optimization:

- Minimize re-renders

- Use keyed each blocks

- Implement virtual scrolling

- Lazy load components

4
Loading Performance:

- Implement preloading strategies

- Optimize images (lazy loading, WebP)

- Use resource hints (preconnect, prefetch)

- Enable HTTP/2 push

- Implement service workers

5
SvelteKit Optimizations:
javascriptcode
   // 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')
     };
   }
6
Optimization Checklist:

- [ ] Enable compression (gzip/brotli)

- [ ] Optimize fonts (subsetting, preload)

- [ ] Minimize CSS (PurgeCSS/Tailwind)

- [ ] Enable CDN/edge caching

- [ ] Implement critical CSS

- [ ] Optimize third-party scripts

- [ ] Use WebAssembly for heavy computation

Example Usage

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

Assistant will:

  • Run performance analysis
  • Identify largest bundle chunks
  • Implement code splitting
  • Optimize images and assets
  • Add preloading for critical resources
  • Configure caching headers
  • Implement lazy loading
  • Optimize server-side rendering
  • Provide performance metrics comparison
  • How to Use & Getting Started

    Protected

    # Step 1: Initialize skill agent setup

    npx skills add Svelte Optimize --install-production

    python -m pip install -r requirements.txt

    codex plugin install Svelte Optimize@latest

    export API_KEY=secret_token_key_here

    Installation Runbook & Walkthrough Locked

    Unlock this skill to reveal complete step-by-step setup guides, terminal commands, configuration recipes, repository links, and interactive installation video walkthroughs.

    Unlock full access to Svelte Optimize

    Get instant access to complete setup guides, repository source code, and integration assets.