Skip to content

Commit ce3f69b

Browse files
authored
perf: wave D — self-host Inter latin subset, preload, font-display: optional (#47)
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.
1 parent d08c823 commit ce3f69b

3 files changed

Lines changed: 25 additions & 2 deletions

File tree

47.1 KB
Binary file not shown.

src/layouts/BaseLayout.astro

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,15 @@ const fullTitle = isHome
5656
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
5757
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
5858

59-
<!-- Fonts (self-hosted via @fontsource-variable to avoid CLS / third-party hop) -->
59+
<!-- Fonts: self-hosted Inter latin subset, preloaded for above-the-fold body text.
60+
The @font-face block lives in src/styles/global.css (font-display: optional). -->
61+
<link
62+
rel="preload"
63+
as="font"
64+
type="font/woff2"
65+
crossorigin="anonymous"
66+
href="/fonts/inter-latin-variable.woff2"
67+
/>
6068

6169
<title>{fullTitle}</title>
6270

src/styles/global.css

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
1-
@import '@fontsource-variable/inter/wght.css';
21
@import '@fontsource-variable/jetbrains-mono/wght.css';
32

3+
/*
4+
* Inter Variable — latin subset only, self-hosted from /public/fonts/.
5+
* Preloaded in BaseLayout.astro <head>. font-display: optional avoids any
6+
* FOUT/CLS contribution: if the font is not ready within ~100 ms the system
7+
* font is used and Inter only swaps in on subsequent navigations (it's
8+
* cached by then). With the preload tag the latin subset typically beats
9+
* that window on first paint anyway.
10+
*/
11+
@font-face {
12+
font-family: 'Inter Variable';
13+
font-style: normal;
14+
font-display: optional;
15+
font-weight: 100 900;
16+
src: url('/fonts/inter-latin-variable.woff2') format('woff2-variations');
17+
}
18+
419
@tailwind base;
520
@tailwind components;
621
@tailwind utilities;

0 commit comments

Comments
 (0)