Repository navigation
perf(widget): lazy-load secondary drawers and preload embed graph - #121
Merged
Merged
Conversation
The three drawers most visitors never open were statically imported by DrawerStack, so every host page paid for the whole Schedule-X stack, react-hook-form and react-share before first paint. Each `lazy` is minted per attempt rather than once at module scope, for the reason EventView already documents: React caches a rejected payload forever, so a module-scope lazy would leave the drawer boundary's "Try again" dead. The existing Suspense sits outside the boundary, so a chunk load shows DrawerLoading — the shared chrome rebuilt from the URL over a spinner — and only a failure throws inward. The drawer keeps its header and close control from the first frame. Closes #96 Co-Authored-By: Claude Fable 5 <[email protected]>
…share eager Lazy-loading the three drawers moved far less than expected, because the heavy components were still reachable from the eager graph through the molecules barrel — which eager views import. Tree-shaking will not drop them: their swiper/react-share imports carry side effects. ImageCarousel, EventActions and ShareContent each have exactly one real consumer, and all of those already sit inside lazily-loaded chunks and reach them by leaf path. Nothing imported them through the barrel, so removing the re-exports is the barrel rule this file follows everywhere else. Worth 44.7 KiB gz of the total, and pinned by a spec, because the size gate catches the bytes but names a budget rather than the line that caused it. Closes #96 Co-Authored-By: Claude Fable 5 <[email protected]>
Vite writes a modulepreload for the entry's whole static closure into index.html, so the standalone page discovers every eager chunk from one parse. embed.js has no shell, and imported only 7 of its 10 chunks directly — the three it missed included `shared`, the largest in the payload. A third of the embed's bytes arrived one round trip late. An injected <link> cannot fix that even in principle: a module's static imports are fetched and evaluated before its body runs, so a hint written from inside embed.js is always later than the graph it would hint at. Appending the missing chunks to the entry's own import list is the same information somewhere a host reads it in time — and appended last, so evaluation order is untouched and they only add fetch parallelism. Also sweeps .DS_Store from the output: publicDir is copied wholesale and has no ignore option, and the file is gitignored, so nobody sees it in review. Closes #96 Co-Authored-By: Claude Fable 5 <[email protected]>
495 -> 395 KiB on both graphs, against 382.1 (standalone) and 383.6 (embed). Same ~3% headroom the previous line carried. The under-budget guard fails until this lands, which is what stops the slack being re-accumulated. Closes #96 Co-Authored-By: Claude Fable 5 <[email protected]>
- Extract flattenEntryImports to scripts/, matching the postcss-scope-widget precedent, and unit-test the graph walk and specifier math. That logic could regress silently: flattening changes discovery, not bytes, so `pnpm size` cannot see it. - The missing-entry guard now errors instead of warning. A warning is as invisible as silence — nothing overrides onwarn and Vite does not fail on rollup warnings — so renaming the input key would have reverted the optimization with every gate green. - Document why only a NON-HASHED entry may be flattened: generateBundle runs after hashing, so rewriting a hashed entry ships bytes that no longer match the hash in their own filename. - stripDsStore: one recursive readdir instead of hand-rolled recursion (the spelling assert-css-scoped already uses), resolve outDir against config.root rather than cwd, and skip a write:false build instead of rejecting. - Fold three overlapping barrel comments into one; drop a comment orphaned by the export it described. Co-Authored-By: Claude Fable 5 <[email protected]>
Lazy-loading the calendar, registration and share panels changes what a host's CSP has to allow: the <script> tag now fetches a small entry which pulls the rest as further script requests from the same origin, and those three panels are fetched only on first open. A policy that allows the tag but not the subresource fetches yields a widget that looks fine and then dies on one of three presses — miserable to diagnose, so the README now says it outright. Also flattens the embed entry's import graph and tightens the embed smoke spec around it. Closes #96 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Deploying sahajatlas-design with
|
| Latest commit: |
671680c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://9d1e1bbc.sahajatlas-design.pages.dev |
| Branch Preview URL: | https://perf-lazy-drawers.sahajatlas-design.pages.dev |
Deploying sahajatlas with
|
| Latest commit: |
671680c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://173cfd6b.sahajatlas.pages.dev |
| Branch Preview URL: | https://perf-lazy-drawers.sahajatlas.pages.dev |
4 of 5 tasks
Ardnived
added a commit
that referenced
this pull request
Aug 7, 2026
One conflict, in README.md's CSP block, and it was load-bearing: this branch added `https://cdn.usefathom.com` to script-src plus a warning that CSP ignores every repeat of a directive name after the first, while #121 added the widget's own origin as a SECOND `script-src` line — the exact mistake the warning describes. Merged onto one line carrying all three sources, so a host pasting the block actually gets Turnstile and Fathom rather than silently losing them, and kept both explanations. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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
Lazy-loads the three secondary drawers and flattens the embed entry's import graph, cutting the eager first-load payload by roughly 100 KiB gzipped.
DrawerStackstatically importedCalendarView,RegistrationViewandShareView, so every visitor downloaded the entire Schedule-X calendar, react-hook-form and react-share before first paint — for panels most never open. The molecules barrel additionally held swiper and react-share eager, defeating the split for consumers that only wanted a neighbouring component.Measured effect (eager payload, gzipped)
Measured with
pnpm size— entry plus the full modulepreload closure for the standalone shell, andembed.js's import graph — never a single chunk, since the build re-chunks freely.standaloneembedBUDGET_KIBis ratcheted 495 → 395 in the same change, asscripts/check-bundle-size.mjsrequires: it fails when a graph comes in far under budget precisely so a win is banked rather than left as slack.Also included
.DS_Storefrom the build output.embed.jssmoke spec around the flattened entry graph.script-srcload-bearing in a way it wasn't before. A host policy that allows the<script>tag but not the subresource fetches now yields a widget that looks fine and then fails on one of three presses.Review coverage — please read
The platform had a sustained API-instability window during this work. The security review completed; both attempts at
/code-reviewdied mid-run, so its findings were triaged inline rather than by a fresh reviewer. A human pass over the lazy-loading seams is worth it.The drawer chrome must render immediately while a lazily-loaded body chunk resolves — the failed-chunk retry pattern from
EventViewis replicated — but that is a behaviour the unit lane cannot express. Manual check worth doing: open the calendar, registration and share drawers on a cold load and confirm no blank or unstyled flash, and that a throttled/failed chunk surfaces the retry rather than an empty panel.Note for merge ordering
#119 (swiper v12) independently reduces the eager payload and is not in this branch, so
BUDGET_KIBmay want one further adjustment once both land.Closes #96