Repository navigation
Description
The question
auto.js (~3 KiB) and embed.js (~302 KiB gz) are two entries because the loader defers fetching
the widget until the embed is near the viewport. The original second reason is gone: the
classic-script bridge built for Wix was removed (git show a94a567) and no Wix client embeds
anything today, so nobody is choosing between entries — every host pastes auto.js.
So the split now buys exactly one thing: an embed below the fold costs a visitor 3 KiB instead of
302 until they scroll to it. Is that worth two entries, a chunk-disjointness assertion, a
duplicated-literals rule and a src/loader/ seam nobody may import across?
Why this is worth investigating rather than just doing
The honest answer is that merging trades a real saving for a simpler contract, and we do not
currently know the size of either side.
- We have never measured how many embeds are actually below the fold. If most clients put the atlas
on a dedicated page, the deferral saves nothing for them and costs everyone the seam. - 302 KiB gz eager is itself the thing worth attacking. The map is already lazy and is not in that
number — so the eager graph is React, react-router, TanStack Query, zod, i18next, framer-motion,
vaul and Radix. If that came down substantially, the case for deferring it weakens on its own.
What to find out
- Measure the eager graph properly.
pnpm sizegives a total; this needs a per-dependency
breakdown. Two candidates named up front: framer-motion (drives the peek strips and a drawer
cross-fade — both plausibly CSS) and zod (runs on every API response, so probably
load-bearing, but worth pricing). - Establish whether deferral is earning anything. The embed report already records each mount;
it does not record whether the embed was in the initial viewport. Adding that is small and would
answer the question with data instead of intuition. - Price the merge. What actually goes away: the
loader/embedsplit in
scripts/check-bundle-size.mjsincluding the closure-disjointness assertion, the duplicated
literals insrc/loader/literals.tsand their pinning spec, and the rule that no value may be
imported across the seam (CLAUDE.md, and feat(widget): send the embed report and publish a readiness marker #153 broke it with a one-line string join). - Check what a merge would cost a host. One entry means the widget is fetched on every page
view of every embed. On a phone on a slow connection, 302 KiB before the visitor has scrolled to
it is not nothing.
Constraints
- Clients must never have to pick an entry. They do not today, and any outcome that reintroduces
that is worse than the status quo. This is the requirement, not the split. - The evergreen caching contract stands either way: root entries revalidate, hashed chunks are
immutable (seedocs/embedding.md→ Updates and caching). - If the merge happens,
docs/embedding.mdandCHANGELOG.mdboth nameembed.jsas a file hosts
may see, and docs(widget): publish an accurate integrator guide #93/docs(widget): publish an accurate integrator guide #144 exist because the README once named a file the build never emitted.
Definition of done
A recommendation with numbers behind it: the per-dependency breakdown of the eager graph, whatever
we can establish about below-the-fold embeds, and either a merge PR or a written reason not to.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Hold Until
Projects
- StatusShow more project fieldsDone
Activity
Ardnived commentedon Oct 28, 2026
Closing as not planned, with the numbers. Measured 2026-10-27 on sahajatlas.com: auto.js and its imports are 2.8 KiB gzipped; embed.js and its imports are 312 KiB. A merge would delete only
literals.tsand the no-shared-code check, because the loader logic (config,detect, most ofindex) is needed either way, and CI already enforces the split. Measuring below-the-fold embeds would need a SahajCloudembedMetadataschema change first. Not worth it; reopen if the split breaks again.