Every page preloads 126 KB of modules to hydrate a page that never changes
The site is a static book: nothing on it holds state or answers a click, yet every page preloads sixteen to eighteen modules and runs a loader before it paints. One line, `csr = false`, removes all of it — 91 % of the transfer — and the text, the fonts and the stylesheet come out byte-identical.
- The problem
- A reader on a phone opens `/mama/brainstorm/` and downloads 82.1 KB gzipped before the page paints, 63.2 KB of it to rebuild DOM the build already wrote. `src/routes/+layout.ts` sets only `prerender` and `trailingSlash`, so SvelteKit keeps client-side rendering on and bundles an app for a site whose every component is a function of constants: a search for `$state`, `$effect`, `onclick` and `addEventListener` across `src/` finds nothing. The build writes 46 `.js` files and 889,455 bytes of output, and the browser is asked for them twice: sixteen to eighteen `modulepreload` links and an inline SvelteKit loader on every page, and `<script src>` on none of them.
- What it is worth
- It serves the reader, who is on a phone more often than not, and the site's own claim: it shows output and does not ask for anything. The largest page drops from 92.7 KB to 13.7 KB gzipped and the median page from 53.6 KB to 5.0 KB, which is the difference between a page that paints on a bad connection and one that waits. It also cuts the build's directory by 40 %, so every deploy uploads 355,585 fewer bytes.
- What it costs
- One line in `src/routes/+layout.ts`, `export const csr = false`, with one comment saying why; then `bun run check`, `bun test` and `bun run build` as they are today, both green on the measured tree. Guarding it costs about 15 lines and ships in the same change, never before it: an assertion that reads the tags of every built page and fails when one carries a modulepreload link or a script src — not a substring, because `.js` matches `/manifest.json` in every head and the word `modulepreload` matches the log page that describes the guard, so a substring test is red on the clean tree — which fails on all 16 pages today and passes with the line in, so the first component that starts holding state turns it red instead of shipping dead JavaScript. Neither `docs/SPEC8N.md` nor `docs/DESIGN.md` restates hydration, so the paperwork is one clause in the spec's architecture line.
- What would kill it
- Anything that needs the browser. The reason this is free is that no component on the site holds state, which is a fact about this tree and not about SvelteKit; the day a page grows a filter, a form or a client-side search, `csr = false` breaks it silently, because the markup still renders and only the handler is gone. The wrong reading is that the site should refuse JavaScript: it should ship none where it runs none. It dies if a page that must ship one is already planned, because then the guard has to be a page list and the line is not one line.
- First step
- Ship the line and the guard in one pull request, then settle it in the build rather than in a browser. One line, one assertion, `bun run build`: 0 of 16 pages carry a preload or a script, and the text is identical across all 16. Measured on `main` at `57f9719` with `bun bench.js`: median page 54,879 → 5,093 bytes gzipped and largest 94,919 → 18,827, 46 `.js` files and 889,455 bytes of build → 0 and 533,870, build 4,332–4,396 → 3,859–3,895 ms, over three paired builds. The harness, its raw runs and the guard are experiment 031 in `thani-sh-mimi/experiments`.