Experiment: bbe6495
rad experiment show bbe649529c18354e8fe687a6550e06ab9c78cbf5
by ee@did:key:z6MkvsiybCuk1WDZhh2aXDx7NTiZejKgWZygMNsUuXDMNvVQ · Apr 11 22:14 2026
inline 3 static stylesheets via hooks.server.ts transformPageChunk
Measurements
MetricBaselineThe benchmark measurement of the unmodified codeCandidateThe code with the proposed optimization appliedDeltaThe performance change from baseline to candidate
page_load_ms (ms) primary60.230 ms (n=1)65.400 ms (n=1)+8.58% REGRESSED
guide_ms (ms) secondary94.100 ms (n=1)98.900 ms (n=1)+5.10% REGRESSED
home_ms (ms) secondary44.200 ms (n=1)49.900 ms (n=1)+12.89% REGRESSED
learn_ms (ms) secondary43.000 ms (n=1)46.600 ms (n=1)+8.37% REGRESSED
Annotations
hypothesisInline global.css + colors.css + typography.css into the prerendered HTML via hooks.server.ts transformPageChunk, eliminating 3 render-blocking CSS fetches from every cold-load sample. Expected savings on localhost vite preview: ~3–9 ms (at or slightly above the 2–6 ms noise floor).
next_action_hintStop targeting render-blocking CSS fetches — free on localhost. Real levers for loadEventEnd on this bench: (1) reduce HTML bytes the parser chews on /guides/user (Shiki 12.5 KB of inline styles across 160 occurrences with only 5 distinct values — extract to class-based rules in the Vite CSS bundle so HTML shrinks AND CSS is served once); (2) reduce hydration work in +layout.svelte; (3) investigate whether mdsvex / Shiki emits redundant wrapper nodes. Do NOT retry any variant of bulk CSS inlining.
rollback_reasonNet regression on every measured route. On localhost the RTT savings from skipping 3 CSS fetches are ~1–2 ms each (below noise), but synchronously parsing an extra 27 KB of CSS inside <style> blocks DOMContentLoaded and therefore loadEventEnd by more than that. bfebd4d (the orphan discard from the prior session) used almost this exact approach; re-running it confirms the prior session measured it and chose correctly.
what_happenedBuild confirms the transform lands: /guides/user.html went from 150 KB to 177 KB with one 27 KB inline <style> and only the Vite bundle CSS left as a render-blocking link. All three routes regressed cleanly: page_load_ms median 60.23 → 65.40 (+8.6%), home 44.2 → 49.9, learn 43.0 → 46.6, guide 94.1 → 98.9. Every individual route is slower.
Base CommitThe starting commit before the optimization was applied02ff0feb90241b5bb161c809ab4f45560c7ad4a8
Candidate CommitThe code with the proposed optimization appliede9a8df5770c1886cbb49196ce1f2b236a0f61aae
Configoptimize.yaml
Diff
+ src/hooks.server.ts
@@ -0,0 +1,24 @@
1+import type { Handle } from "@sveltejs/kit"; 2+import globalCss from "../static/global.css?raw"; 3+import colorsCss from "../static/colors.css?raw"; 4+import typographyCss from "../static/typography.css?raw"; 5+ 6+const inlineTag = `<style>${globalCss}\n${colorsCss}\n${typographyCss}</style>`; 7+ 8+const linkRegex = 9+ /<link[^>]*href="[^"]*(?:global|colors|typography)\.css"[^>]*>/g; 10+ 11+export const handle: Handle = async ({ event, resolve }) => { 12+ return resolve(event, { 13+ transformPageChunk: ({ html }) => { 14+ let first = true; 15+ return html.replace(linkRegex, () => { 16+ if (first) { 17+ first = false; 18+ return inlineTag; 19+ } 20+ return ""; 21+ }); 22+ }, 23+ }); 24+};
Environment
Buildtrue
Teststrue
Archaarch64
OSDarwin 14.6.1
CPUApple M2
Agentpi-autoresearch / pi
Filessrc/hooks.server.ts