Cut bundled JS 91% by lazy-loading explanation text; add SEO metadata#61
Open
MaxGhenis wants to merge 2 commits into
Open
Cut bundled JS 91% by lazy-loading explanation text; add SEO metadata#61MaxGhenis wants to merge 2 commits into
MaxGhenis wants to merge 2 commits into
Conversation
data.json (57MB raw, 3.5MB gzipped) was statically imported into the
client bundle, so every visitor downloaded and parsed it before the page
became interactive. 85% of it is free text: referenceExplanation alone
is 33MB and repeated verbatim for every model on the same case.
A prepare-data step (wired into dev/build) now splits data.json into:
- src/data-summary.json: every numeric field, bundled (0.3MB gzipped)
- public/data/explanations-{us,uk}.json: deduped reference narratives
plus per-model explanation/annotation text, fetched only when the
scenario explorer approaches the viewport
The bundled summary is ASCII-escaped because Turbopack's dev JSON-module
loader mis-parses multi-byte UTF-8 (the module resolves to undefined).
Also:
- Open Graph/Twitter metadata with a generated og-image.png, canonical
URLs, sitemap.xml, and robots.txt (the site had no social previews or
crawler configuration)
- error.tsx boundary so runtime failures don't render a blank page
- Round-trip tests for the split/merge in app/tests/explanations.test.ts
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jun 10, 2026
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.
Why
policybench.org currently ships a 3.5MB-gzipped (55MB raw) JS chunk because
app/src/data.jsonis statically imported into the client bundle. Measured on the live site, the main chunk is 3,541,196 bytes compressed — all of it downloaded and parsed before the page is interactive.85% of that payload is free text, and most of it is redundant:
referenceExplanationis 33MB and verified byte-identical across all models for each (scenario, output) case.What
Performance (main chunk: 3.54MB → 0.30MB gzipped, −91%; 55MB → 10MB raw):
app/scripts/prepare-data.tsruns beforenext dev/next buildand splitsdata.jsoninto a bundled numeric summary plus per-country explanation sidecars (public/data/explanations-{us,uk}.json, 2.0MB/0.9MB gzipped)referenceExplanationis deduplicated to one string per case (round-trip covered by tests)data.jsonremains the only artifact benchmark exports writeSEO (the site had no social previews or crawler config):
og-image.png(PolicyEngine tokens),metadataBase, canonical URLs on/and/papersitemap.xmlandrobots.txtroutesResilience:
error.tsxboundary so a runtime error no longer renders a blank page.Notes
json.dump) because Turbopack's dev JSON-module loader mis-parses multi-byte UTF-8 — the module resolves toundefined. Reproduced on Next 16.2.6;next buildis unaffected.bun run lint,bun test(13 pass),bun run build, plus a productionnext startrun confirming SSR content, sidecar fetch + merge (coverage card renders real counts), sitemap/robots/OG tags.Also done outside this PR: repo homepage URL fixed (pointed at dead
policybench.vercel.app, nowpolicybench.org), andwww.policybench.org(previously 401) now 308-redirects to the apex via project domain config.🤖 Generated with Claude Code