Skip to content

perf(www): move heavy route deps out of the critical import graph - #627

Merged
mehdibha merged 3 commits into
mainfrom
claude/landing-page-performance-f9659a
Aug 28, 2026
Merged

perf(www): move heavy route deps out of the critical import graph#627
mehdibha merged 3 commits into
mainfrom
claude/landing-page-performance-f9659a

Conversation

@mehdibha

Copy link
Copy Markdown
Owner

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/beforeLoad stay in the router's critical import graph — and everything they touch ships on every page:

  • docs/$.tsxclientLoader (with the whole MDX render component inside) is referenced by the loader → the entire docs pipeline incl. shiki (~330 KB raw) in the entry
  • demos/$slug.tsx — module-level helper → the full demos barrel (215 KB raw)
  • preview/$slug.tsxbeforeLoad + module promise cache → examples barrel, components-list, and decodePresetpako
  • __root.tsxcreate/preset barrel import → codec → pako again

Fix

  • Move each route's component + heavy deps into non-route -page.tsx files; loaders warm them via dynamic import of the same module (same chunk the component needs — no extra fetch).
  • Deep-import the create/preset barrel where only DEFAULTS/hooks/types are needed, keeping the codec (pako) out of the root graph.
  • Request the landing showcase GitHub avatars at 96px (?size=96) instead of full size (shuding's was 254 KB → 11 KB; ~430 KB saved across six).

Result (measured on the prod build)

before (prod today) after
entry chunk gz 454 KB 215 KB (−53%)
landing modulepreloads 140 46
preloaded total gz 858 KB 406 KB (−53%)
Lighthouse mobile (local, gzip) 58 60 — FCP 6.8→5.0s, LCP 9.1→5.0s

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

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.
@vercel

vercel Bot commented Aug 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dotui Ready Ready Preview Aug 28, 2026 9:46pm

@github-actions github-actions Bot added the area: www The dotui.org app: site, landing, docs pages label Aug 22, 2026
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.
@mehdibha
mehdibha merged commit de8c7c6 into main Aug 28, 2026
11 checks passed
@mehdibha
mehdibha deleted the claude/landing-page-performance-f9659a branch August 28, 2026 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: www The dotui.org app: site, landing, docs pages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant