Svelte Optimize

A command for svelte workflows.

CommandsvelteMIT1 source files

Before you use this component

This is a third-party source bundle, not an installation into your account. UI Discovery has checked the available redistribution license evidence; runtime behavior has not been tested. Review all files, use a disposable project first, and do not enable scripts or hooks until you understand their permissions.

Some integrations require separately installed software, API keys or paid services. Credentials and subscriptions are not included. These are Claude Code resources; other clients may require adaptation.

Extract the ZIP into a temporary folder, inspect its entry file and supporting resources, then follow the original instructions. Do not overwrite an existing project configuration blindly. Keep the bundled license and attribution notices.

Source publisher
Claude Code Templates
Creator supplied by source
Not listed in source
Pinned source version
a344359459263d73d8948651c789244093c02e4e
License evidence
LICENSE

Source preview

cli-tool/components/commands/svelte/svelte-optimize.md

# /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**:
   ```javascript
   // 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**:
   ```javascript
   // 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**:
   ```javascript
   // 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

Preview capped at 60,000 characters. Download the bundle for every original file and notice.

Read the redistribution license
MIT License

Copyright (c) 2025 Daniel (San) Ávila

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Bundle SHA-256: 9f0ec7466e9c0c55a5c44a3cf2c8f96a20f1c14d4a56d4220ec1877dc48afa49. Files are served as downloads and are never executed by this page.