How do you optimize SvelteKit performance for production?

Answer

SvelteKit production optimization strategies: Prerender aggressively: static HTML is fastest — prerender all pages that don't need per-request data. Streaming SSR: return unresolved promises from load functions; SvelteKit streams HTML with deferred data — the browser renders what's available immediately. Code splitting: SvelteKit splits bundles per route automatically — users only download code for pages they visit. Link preloading: data-sveltekit-preload-data="hover" fetches data on hover for instant-feeling navigation. Svelte 5 runes: fine-grained reactivity only updates exactly what changed, no unnecessary component re-renders. CSS: Svelte's scoped CSS is tree-shaken — unused component styles are not included. Image optimization: use <enhanced:img> for automatic WebP/AVIF conversion and responsive sizes. Cache headers: set long cache headers on immutable assets (content-hashed), short TTL on dynamic content. Edge deployment: deploy to Cloudflare Workers or Vercel Edge for global low-latency SSR. Measure: use Lighthouse, Web Vitals, and the Vite bundle analyzer to identify actual bottlenecks.