Repository navigation
Make the first visit paint and fill in sooner (Fix #516) - #518
Open
stephaniehobson wants to merge 12 commits into
Open
stephaniehobson wants to merge 12 commits into
stephaniehobson wants to merge 12 commits into
Conversation
stephaniehobson
force-pushed
the
516--first-load-performance
branch
from
November 19, 2026 20:43
001824f to
222d390
Compare
… without waiting for load (#516)
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Sitewide fallback-font changes need Safari and Firefox validation, while Chromium dev-server coverage leaves production preload timing and font-swap behavior unverified.
No open issues 🎉
What changed in this PR
This PR addresses #516 by improving first-load performance in the Firefox Public Data Report. It shows navigation before JavaScript runs, starts dashboard requests earlier, and reduces layout shifts during loading.
Changes:
- Add a static header shell, route preloads, and cached dashboard prefetching.
- Stabilize loading layouts and font swaps, preserve keyboard focus, and skip analytics for the placeholder ID.
- Add regression coverage and document the implementation, measurements, and follow-ups.
| File | Description |
|---|---|
vite.config.mjs |
Register the HTML shell and preload plugin. |
tests/playwright/specs/jsDisabled.spec.js |
Check header links without JavaScript. |
tests/playwright/specs/fixtures/shell.spec.js |
Check shell consistency, styling, layout, and focus handoff. |
tests/playwright/specs/fixtures/next-buttons.spec.js |
Check that proceed buttons stay hidden during dashboard loading. |
tests/playwright/specs/fixtures/font-fallback.spec.js |
Measure layout shifts when webfonts arrive. |
tests/playwright/specs/fixtures/early-data.spec.js |
Check that dashboard data requests precede code arrival. |
src/tests/jest/withTracker.test.jsx |
Cover analytics guards and page-view addresses. |
src/tests/jest/withFetch.test.jsx |
Cover prefetch reuse, shared requests, and failure retries. |
src/tests/jest/Routes.test.jsx |
Update analytics setup and page-view assertions. |
src/tests/jest/indexHtmlPlugin.test.jsx |
Cover shell generation and preload selection. |
src/lib/withFetch.jsx |
Expose cached JSON prefetching. |
src/lib/utils.js |
Add a shared dashboard index URL helper. |
src/index.jsx |
Prefetch dashboard data and preserve shell-link focus. |
src/components/views/styl/Spinner.styl |
Hide proceed buttons while dashboards load. |
src/components/views/styl/includes/lib.styl |
Add adjusted fallback fonts to font stacks. |
src/components/views/styl/Application.styl |
Define fallback faces and reserve loading space. |
src/components/views/Header.jsx |
Add a comment linking header maintenance to the shell copy. |
src/components/decorators/withTracker.jsx |
Guard analytics initialization and attach page-view addresses. |
src/components/containers/DashboardContainer.jsx |
Use the shared dashboard URL helper. |
scripts/indexHtmlPlugin.mjs |
Generate the shell, production preloads, and development stylesheet links. |
docs/execplans/2026-11-18-first-load-performance.md |
Record decisions, performance measurements, and follow-ups. |
docs/architecture/frontend.md |
Document startup prefetching and shell behavior. |
CONTRIBUTING.md |
Explain placeholder analytics behavior and test setup. |
AGENTS.md |
Update repository guidance for loading, fonts, and analytics. |
Review effort: Balanced
This branch has not been deployed
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.
One-line summary
Make a first visit paint and fill in sooner on slow connections, and stop the page jumping while it loads.
Significant changes and points to review
src/index.jsxrequests the current dashboard'sindex.jsonat startup, through the newprefetchJSONinwithFetch.jsx.scripts/indexHtmlPlugin.mjs:maininto#root, generated fromconfig.json, so the header paints before any JavaScript runs;modulepreloadlinks for the route chunks and what they import, pluspreloadlinks for their CSS. The chart chunk and the fonts are deliberately left out, because they slowed the main script down on a slow connection;Application.cssandHeader.cssfrom the head so the shell isn't unstyled. Hot reload doesn't update those links.src/index.jsxmoves focus to the same link in React's header.mainstays a window tall while it is empty or shows only the page spinner.Application.styl: Arial, or Liberation Sans or Arimo, scaled to the Mozilla fonts' widths so text doesn't move when they arrive.Issue / Bugzilla link
Fix #516
Testing
The timings only show on a production build:
npm run buildnpx vite preview --port 4173Then:
Home,Contact,DashboardContainer,NotFound,Metric,StripedHeader) start alongsideindex-*.js, the chart chunk starts later, anduser-activity/index.jsonstarts as soon asindex-*.jsfinishes.googletagmanager.com.npm start, load http://localhost:3000/, and check the header isn't unstyled before the page appears.