perf: wave D — self-host Inter latin subset, preload, font-display: optional#47
Merged
Conversation
…ptional Replaces the @fontsource-variable/inter @import with a self-declared @font-face block targeting a single 48 KiB latin subset shipped from /public/fonts/inter-latin-variable.woff2, plus a <link rel="preload"> in BaseLayout.astro so the font byte stream races CSS parsing. - Removes 6 unused @font-face blocks (cyrillic, cyrillic-ext, greek, greek-ext, vietnamese, latin-ext) that fontsource ships by default — the site is English-only. - font-display: optional eliminates FOUT/FOIT entirely; with the preload tag the latin subset typically arrives before first paint. - Cache rule already in place from wave A (/fonts/* immutable, max-age=31536000), so repeat visits skip the network round-trip. JetBrains Mono kept on @fontsource for now — only used in below-fold code blocks, not critical path. Part of audits/perf-2026-05/ remediation. Lighthouse re-run pending.
|
🚀 Preview deployed to: https://c1729110.gemmology-dev.pages.dev |
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.
Summary
Replaces the
@fontsource-variable/interCSS@importwith a self-declared@font-faceblock targeting a single 48 KiB latin subset shipped from/public/fonts/inter-latin-variable.woff2, plus a<link rel="preload">inBaseLayout.astroso the font byte stream races CSS parsing.Changes
src/styles/global.css— removed the Inter@fontsource-variable@import(which shipped 7@font-faceblocks: cyrillic, cyrillic-ext, greek, greek-ext, vietnamese, latin-ext, latin); replaced with a single@font-faceblock for the latin subset withfont-display: optional.src/layouts/BaseLayout.astro— added<link rel="preload" as="font" type="font/woff2" crossorigin="anonymous" href="/fonts/inter-latin-variable.woff2">to<head>.public/fonts/inter-latin-variable.woff2— new file (48 KiB), copied from the fontsource latin subset.Why
@font-facedeclarations for character ranges the English-only site never renders.font-display: optionalmeans if the font isn't ready within ~100 ms the system font is used and Inter swaps in only on subsequent navigations (cached by then). The preload tag means the latin subset typically arrives before first paint anyway._headersrule covers/fonts/*withCache-Control: public, max-age=31536000, immutable, so repeat visits skip the network round-trip entirely.JetBrains Mono kept on
@fontsource— only used in below-fold code blocks, not critical path.WD2 (scope
.monaco-editor/.skeleton/.proseoverrides) deliberately skipped —.proseis used by ~10 routes (every learn/tools/quiz page), so a separate import wouldn't materially reduce unused CSS; the.monaco-editorand.skeletonrules are <20 lines combined. Marginal benefit, not worth the refactor.Test plan
npm run build— 916 pages built in 9.04s, no errors/fonts/inter-latin-variable.woff2returns 200 with the immutable cache header after deploy