perf(www): move heavy route deps out of the critical import graph - #627
Merged
Conversation
Route files' module-level bindings (docs clientLoader, demos barrel helper, preview examples cache) ride in the router's critical graph on every page. Moving them to non-route -page files cuts the landing entry from 454 to 215 KB gz and preloads from 140 to 46. Also deep-import the create/preset barrel to keep pako out of the root graph, and request GitHub avatars at 96px instead of full size.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The font stacks referenced "Geist Variable Fallback" but no such @font-face existed, so font-display: swap reflowed the page when Geist arrived — shifting the landing showcase (CLS 0.102 on throttled loads). Define capsize-adjusted fallback faces for Geist, Geist Mono and Josefin Sans so the swap is paint-only. Lighthouse CLS: 0.102 -> 0-0.002 across runs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Prod landing page scores 58 on Lighthouse mobile (FCP 6.8s, LCP 9.1s). The SSR HTML arrives in ~400ms, but every page modulepreloads 140 chunks / 858 KB gz (entry chunk alone 454 KB gz), saturating a mobile connection before first paint.
Route-level code splitting is on (Start default), but module-level bindings in route files referenced by
loader/beforeLoadstay in the router's critical import graph — and everything they touch ships on every page:docs/$.tsx—clientLoader(with the whole MDX render component inside) is referenced by the loader → the entire docs pipeline incl. shiki (~330 KB raw) in the entrydemos/$slug.tsx— module-level helper → the full demos barrel (215 KB raw)preview/$slug.tsx—beforeLoad+ module promise cache → examples barrel, components-list, anddecodePreset→ pako__root.tsx—create/presetbarrel import → codec → pako againFix
-page.tsxfiles; loaders warm them via dynamic import of the same module (same chunk the component needs — no extra fetch).create/presetbarrel where onlyDEFAULTS/hooks/types are needed, keeping the codec (pako) out of the root graph.?size=96) instead of full size (shuding's was 254 KB → 11 KB; ~430 KB saved across six).Result (measured on the prod build)
Hero LCP element render delay: 2742ms → 132ms. Local Lighthouse understates the win (no brotli/CDN) — please check the Vercel preview score on this PR.
Verified in the browser on the prod build: landing, docs (code highlighted), /create (iframe + controls), /preview/$slug all render; the only console error (React #418 hydration mismatch on docs) exists on prod today, unrelated.
Suggested refactors
validateSearchschemas — in progress separately, along with lazy search dialog and a CI perf budget (resurrecting ci(www): add client bundle perf budget check #419; the closed perf(www): move shiki off the entry bundle #415–419 batch never merged, which is how this regressed silently).