Guides

Code splitting and tree shaking plan for each route

Use this page to see where the public marketing site spends bytes, which chunks to split first, and how much each route can save on first load. Estimates come from the source files in pack app-campus.site.2 and are labeled as estimates. Confirm each estimate against the production bundle before you ship a split.

What the pack shows and what it does not show

The pack holds 18 public guide HTML files. Every guide references the shared theme.css, site.css and site.js. The pack holds no built JavaScript bundle, no source map, no signed-in app screen files and no lockfile, so no production chunk size can be read from this pack alone. Largest chunks in the tables below are therefore measured as inline script bytes, inline style bytes and inline SVG bytes in the source HTML. A signed-in app split must be sized from the production build of the app shell, which is not in this pack.

Shared on every route

  • theme.css and site.css for layout and components, loaded as stylesheets on every guide
  • site.js with defer for the menu button and site analytics, loaded on every guide
  • Header, navigation and footer markup repeated in every guide file

Not in this pack

  • Built bundle files, chunk names and source maps for the marketing site
  • Signed-in app views in public/app and app modules in src/app, so app route savings cannot be sized here
  • Any unused dependency list from a lockfile, because no lockfile is included

Inventory by route, with estimated initial saving

Read the row for your route. Estimated saving is the reduction in bytes parsed on first load after the split in the next section, shown as a range to allow for compression differences. It is an estimate from source size, not a measured production result.

Largest source chunk per guide route in pack app-campus.site.2, with split candidate and estimated saving
RouteLargest chunk in sourceSplit or tree shake candidateEstimated initial saving
weekly-quality-rateTwo large inline scripts for the quality instrument and the campaign tool, plus a large inline responsive style blockExtract each script to a hashed asset and load it when its section enters view, move the style block to a hashed asset18 to 24 KB, about one third of the page
share-answerOne large inline script for the share copy tool, with copy, download, encode and preview helpersExtract the share tool script to a hashed asset and load it when the tool enters view10 to 14 KB
role-first-runOne large inline script for role checklists and progress storage, plus an inline style block for the tabsExtract the checklist script and style to hashed assets and load the script when the checklist enters view9 to 12 KB
verified-expertOne large inline script for the canonical eligibility checker, with copy, download and save helpersExtract the checker script to a hashed asset and load it when the checker enters view8 to 11 KB
work-unansweredDuplicate preload links for theme.css and site.css, plus a large inline SVG diagram and long sectionsRemove the duplicate preload links, keep the stylesheet links, lazy load the SVG with its existing content visibility pattern4 to 7 KB of fetch and parse work
test-answersInline SVG diagram and a small inline focus style block, otherwise staticLazy load the SVG and move the focus style into the hashed page style asset3 to 5 KB
save-answer-bundleOne small inline script for the save example on this pageExtract the example script to a hashed asset and load it when the example enters view2 to 3 KB
unified-form-layoutInline style block for form layout examples, otherwise staticMove the style block to a hashed asset so it can be cached by content hash1 to 2 KB on first load, more on repeat load from cache
role-features, role-home-view, search-indexing, search-scopeStatic tables and prose, no inline script beyond the shared site.js, role-home-view holds a mermaid code block as textNo page script to extract, share the site.js split below, keep the mermaid block as text and do not load a diagram library for it1 to 3 KB from the shared site.js split only
set-notification-preferences, set-retention-and-access, spanish-help, stale-question-reminders, student-workflows, workspace-member-auditStatic prose, no inline script beyond the shared site.js, stale-question-reminders holds structured data as JSON textNo page script to extract, share the site.js split below1 to 3 KB from the shared site.js split only

The signed-in app shell has no screen files in this pack, so no per route saving is stated for signed-in routes here. Size that split from the production build and apply the same order of steps below.

Shared chunks and tree shaking

Apply these shared steps once and every route benefits. Do not change the cache rule for unhashed files such as site.css or site.js. Content hashed files under the assets path can be cached for a long period.

Split site.js by use

  • Keep a small navigation chunk on every route for the menu button, loaded with defer as today
  • Move analytics recording to a separate chunk loaded on browser idle, so a reader who only reads prose does not pay for it on first load
  • Estimated saving on first load is 1 to 3 KB per route, with the full saving confirmed in the production bundle

Remove repeated helpers

  • Opt out check, download helper and copy helper text appear in share-answer, weekly-quality-rate, verified-expert and save-answer-bundle
  • Move those helpers to one shared hashed chunk loaded only by a route that has a tool, instead of repeating them inline per page
  • Estimated saving is about 3 KB per tool route after the shared chunk is loaded on demand

Tree shake page styles and diagrams

  • Move per page inline style blocks to hashed assets, so repeat visits use the cached asset instead of reparsing the HTML
  • Load inline SVG diagrams only when their section enters view, using the content visibility pattern already used in work-unanswered
  • Do not load a mermaid or chart library for a code block that is shown as text, as in role-home-view

What not to shake

  • Do not remove theme.css or site.css rules by guessing use, confirm use in the production build for each route first
  • Do not add long lived caching to unhashed files whose names do not change between versions
  • Do not remove a guide, a link or a help text to save bytes, those are content and accessibility, not unused code

Code splitting steps, in order

Ship in this order, one step per release, and measure after each step.

  1. Step 1: Inventory the production bundle

    Build the marketing site and the signed-in app shell, read chunk sizes from the build output and source maps, and replace the source estimates in the table above with measured chunk sizes per route. Record the build date and the route list used.

  2. Step 2: Split weekly-quality-rate first

    Extract the quality instrument script and the campaign tool script to two hashed assets, load each when its section enters view, and move the inline style block to a hashed asset. This route holds the largest inline chunk and shows the largest saving.

  3. Step 3: Split share-answer, role-first-run and verified-expert

    Extract each tool script to a hashed asset, load it when its tool enters view, and move the repeated helpers to the shared chunk from the previous section. Keep every tool control and label unchanged.

  4. Step 4: Split site.js and remove duplicate preloads

    Split site.js into the navigation chunk and the idle analytics chunk, and remove the duplicate preload links in work-unanswered while keeping the stylesheet links. Confirm the menu button still works on phone and desktop.

  5. Step 5: Lazy load diagrams and move page styles

    Lazy load the SVG diagrams in test-answers and work-unanswered, and move the remaining per page style blocks to hashed assets. Keep focus visible and tap targets at least 44 pixels as stated in the form and search guides.

  6. Step 6: Measure and keep the gain

    Rebuild, read the new chunk sizes per route, and confirm the saving on weekly-quality-rate, share-answer, role-first-run and verified-expert matches the estimate within the stated range. If a route saves less than estimated, keep the split only when the tool still works and the page is faster to first content.

Try the estimator on this page

Choose a route, check the steps you plan to ship, and read the estimated saving. Nothing entered here is sent to a server. Copy or download the plan and paste it into the build note for that route.

Static guide covers role-features, role-home-view, search-indexing, search-scope, set-notification-preferences, set-retention-and-access, spanish-help, stale-question-reminders, student-workflows and workspace-member-audit.

Use the measured chunk size from the production build when you have it. The value for the route is filled in when you change the route.

Steps in the plan

Choose a route and steps, then choose Estimate saving.

    Checks before you ship a split

    Run each check on phone and desktop with keyboard before you publish.

    • Each tool route still works after the split, with the same controls, labels, status messages and downloads as before
    • The menu button works on every route after the site.js split, with focus visible and tap targets at least 44 pixels
    • First load parses less inline script on weekly-quality-rate, share-answer, role-first-run and verified-expert, and the measured saving is recorded beside the estimate
    • No unhashed file gains long lived caching, and every new asset is under the assets path with a content hash in its name
    • Build and existing tests pass, and no sign in, permission, tenancy or security setting changes in the same release

    Next guide

    Keep search scope labels clear on every route after a split.