Repository navigation
perf: headroom under the public lanyard's loading budget (#177) - #179
Merged
Merged
Conversation
Rolldown split the code the entry shares with lazy routes into seven small chunks of its own, so every page started with eight JavaScript files. Over HTTP/1.1, with six connections per host, they queued behind each other and the font. A group for the entry's code ($initial) puts it back in the entry: one file, and 3.3 KB less to download gzipped. The public lanyard's median LCP under the perf test's throttling moves from about 2,300 ms to 2,260 ms (nine cold loads each). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PSPB1dNXrwbP6tbCDtjLb9
Once the entry has run, a public lanyard loads its route's code: eleven small files, one for each set of pages sharing a module. Over HTTP/1.1 the last five waited for a free connection, a second round trip before the badge could render. A chunk group's name function now reads the module graph and sorts what the public lanyard loads lazily into two chunks: - lanyard-page: what only a person's lanyard pages load (the public lanyard, the owner's own, the customiser and Share); - lanyard-shared: what a lanyard shares with other pages, such as the badge's drawing on the homepage and sign-in, which the badge group (#173) held, and small helpers. The build fails if a lanyard route stops being split, so the list can't drift. The lanyard now loads five lazy files (two of them tiny lucide icons, which reach it through the entry's barrel), and 194.6 KB of initial JS against 199.8 KB. The homepage, sign-in, feedback and the customiser load fewer files and less JS; a cold load of Share loads the lanyard's surface too (+15 KB gzipped), which a visit from the owner's lanyard has already loaded. The public lanyard's median LCP under the perf test's throttling moves from about 2,260 ms to 2,140 ms (nine cold loads each). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PSPB1dNXrwbP6tbCDtjLb9
The router asks for the current route's lazy code only once React has rendered and the router has started. preloadRouteCode, called from main.tsx before the first render, matches the location and starts that download as soon as the entry has run. It loads code only: each route's beforeLoad and loader still run once, when the router loads it, and the router waits on the same download, so a failure shows as the route's error, as before. The public lanyard's chunks are requested about 85 ms earlier, and its median LCP under the perf test's throttling moves from about 2,140 ms to 2,060 ms (eighteen cold loads). Against the original build, interleaved on one machine: 2,280–2,300 ms before, 2,060–2,110 ms after. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PSPB1dNXrwbP6tbCDtjLb9
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Base automatically changed from
claude/lanyards-rebuild-attendee-ux-vcl1sb
to
main
November 21, 2026 16:37
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.
Summary
The public lanyard's LCP sat on its 2.5 s budget, so
e2e/perf.spec.tsfailed intermittently. Three changes, one commit each, give it about 230 ms of headroom.An interleaved A/B against the original build on the same machine gave 2,280–2,300 ms before and 2,060–2,110 ms after, with a tighter spread. This machine runs about 170 ms faster than the one in the issue, so expect about 2,250–2,300 ms there.
1. Entry merge (
vite.config.ts)Rolldown split the code the entry shares with lazy routes into seven extra chunks, so every page started with eight JS files on HTTP/1.1's six connections. A
$initialgroup puts that code back in the entry, which also saves 3.3 KB gzipped.2. Lanyard chunk groups (
plugins/lanyardChunks.ts)A chunk group's
namefunction reads the module graph and sorts what the public lanyard loads lazily into two chunks:lanyard-page: code that only a person's lanyard pages load (public, own, customiser, Share).lanyard-shared: code a lanyard shares with other pages, including the badge's drawing. This replaces thebadgegroup from A person's lanyard page hangs its badge from a printed lanyard, in the laminate sleeve #173.The build fails if a listed lanyard route stops being split, so the list can't drift. The lanyard's lazy burst drops from 11 files to 5. Two of those five are tiny lucide icons, which reach it through the entry's barrel.
3. Early route preload (
src/app/preloadRouteCode.ts)Called from
main.tsxbefore the first render, it matches the location and starts the route's code downloading. It loads code only:beforeLoadand loaders still run once, and the router waits on the same download, so a failure still shows the route's error. Tests cover both.Bundle sizes (gzipped, cold load)
/$handle(budget 200 KB)/d/$didTrade-off: a cold load of Share now includes the lanyard's surface (+15 KB). Share is normally opened from your own lanyard, which has already loaded that code, so in practice it rarely costs anything.
What I tried and rejected
index.html: made LCP worse (median ~2,380 ms). DevTools throttling shares bandwidth regardless of fetch priority, so the chunks slowed the entry. It also exposed the three-hop data chain (profile → DID document → PDS) as the next critical path.Testing
npm run lint,npm run typecheck,npm run lex:check,npm run i18n:checknpm test -- --run: 1,359 passed, including 13 new testsnpm run build:e2e,npm run size,npm run check:prodnpm run e2e: 95 passed, including perf; the perf spec alone passed 5 of 5 runsNotes
claude/lanyards-rebuild-attendee-ux-vcl1sb(Bug: signing out leaves you on Settings instead of the homepage #172–Real lanyard physics: straps and badge sway together; the Share lanyard sways like home's #174), where thebadgegroup lives. GitHub retargets it tomainonce that branch merges.Closes #177
Generated by Claude Code