Performance: Page options (SSR, CSR, prerender)
This affects how fast the main content appears and how quickly users can interact with the page.
export const ssr = true; <script context="module"> export async function load() { const res = await fetch('/api/data'); const data = await res.json(); return { props: { data } }; } </script> <script> export let data; </script> <main>{JSON.stringify(data)}</main>
export const ssr = false; <script> import { onMount } from 'svelte'; // fetch data on client only let data; onMount(async () => { const res = await fetch('/api/data'); data = await res.json(); }); </script> <main>{data ? JSON.stringify(data) : 'Loading...'}</main>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| CSR only | Minimal initial DOM, built on client | Multiple reflows as content loads | High paint cost on load | [X] Bad |
| SSR | Full DOM sent from server | Single reflow on load | Lower paint cost | [OK] Good |
| Prerender | Static full DOM | Single reflow on load | Lowest paint cost | [OK] Good |
export const ssr = false; disables server-side rendering.prerender controls static generation, csr is not a valid option, and ssr = true enables SSR.export const prerender = true; export const ssr = false;
prerender = true means the page is built as a static HTML file ahead of time. Setting ssr = false disables server-side rendering on requests.export const ssr = false; export const prerender = false;
ssr = false disables server-side rendering, and prerender = false disables static generation.Pass the test and this pattern moves unknown