Performance: SvelteKit overview
MEDIUM IMPACT
SvelteKit affects page load speed by optimizing server rendering and client hydration, reducing JavaScript bundle size and improving interaction responsiveness.
export async function load({ fetch }) { const res = await fetch('/api/data'); const data = await res.json(); return { data }; } <p>{data.text}</p>
import { onMount } from 'svelte'; let data; onMount(async () => { const res = await fetch('/api/data'); data = await res.json(); }); {#if data} <p>{data.text}</p> {/if}
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Client-side data fetch in onMount | High (delayed DOM update) | Multiple reflows during hydration | High paint cost due to delayed content | [X] Bad |
| Server-side data fetch with load function | Low (HTML ready on load) | Single reflow on initial paint | Low paint cost, fast LCP | [OK] Good |