8000 docs: stop the header shifting on page load by hipstersmoothie · Pull Request #1544 · jimp-dev/jimp · GitHub
[go: up one dir, main page]

Skip to content

docs: stop the header shifting on page load - #1544

Merged
hipstersmoothie merged 1 commit into
mainfrom
fix/docs-header-jiggle
Nov 24, 2026
Merged

hipstersmoothie merged 1 commit into
mainfrom
fix/docs-header-jiggle

Conversation

@hipstersmoothie
Copy link
Copy Markdown
Collaborator

The docs header jiggled on load. Measured with Playwright's layout-shift observer, there were three causes:

  1. Downloads badge count-up. The number counted through different units (120K … 4.5M), so the badge's width changed every frame and pushed the search box, GitHub pill and theme switch back and forth for about 1.4s. It now counts in the final unit (0.0M → 4.5M) over a hidden copy of the final value, so its width never changes.
  2. Search box jumping 480px. Starlight's search runs an inline script in the middle of the header. Chrome could paint at that point, before the pills after it were parsed, so the search box first painted at the right edge and then jumped left. Head.astro now adds <link rel="expect" href="#header-end" blocking="render">, which holds the first paint until the end of the header is parsed. Browsers that don't support it ignore it.
  3. Web font swap. The fonts came from Google Fonts CSS, which paints in the system font first and then swaps. They're now self-hosted with Astro's fonts API, which generates metric-matched fallbacks and preloads the faces the header and hero use first.

What's left is one small settle when the webfonts replace their fallbacks (CLS about 0.0005; the nav is about 20px narrower in Fredoka than in its Arial fallback). That's well below the 0.1 "good" threshold, and it happens once instead of throughout the count-up.

Checked on /, /methods/blur/, /guides/getting-started/ and /playground/. The production build passes (230 pages).

🤖 Generated with Claude Code

- Keep the downloads badge a fixed width while it counts up: the count
  stays in its final unit and sits over a hidden copy of the final value.
- Self-host the fonts with Astro's fonts API (metric-matched fallbacks,
  preloads for the header and hero faces) instead of Google Fonts CSS.
- Hold Chrome's first paint until the whole header is parsed, so the
  search box no longer paints at the right edge before the pills exist.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hipstersmoothie hipstersmoothie added the documentation Changes only affect the documentation label Nov 24, 2026
@hipstersmoothie
hipstersmoothie merged commit 8123931 into main Nov 24, 2026
13 of 14 checks passed
@hipstersmoothie
hipstersmoothie deleted the fix/docs-header-jiggle branch November 24, 2026 05:31
@hipstersmoothie
Copy link
Copy Markdown
Collaborator Author

🚀 PR was released in v2.1.0 🚀

@hipstersmoothie hipstersmoothie added the released This issue/pull request has been released. label Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Changes only affect the documentation released This issue/pull request has been released.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0