From 83afdb21aa8fa1e060fc3a7e10d50e5979e2858b Mon Sep 17 00:00:00 2001 From: Brian Love Date: Wed, 23 Sep 2026 08:31:42 -0700 Subject: [PATCH] perf(website): preload only the H1 and body faces On a throttled phone the CDN splits bandwidth between concurrent requests rather than honoring priority, so every preloaded font races the hero poster, the LCP element. Measured on production (Lighthouse mobile, devtools throttling), blocking Archivo italic moved LCP -228ms and JetBrains Mono -224ms, each more than PostHog's whole library. - JetBrains Mono is no longer preloaded, and gets a real monospace fallback stack. next/font's generated fallback for it was local(Arial), a proportional font that would misalign code while the face loads. - Archivo is split into two next/font instances so its italic can skip the preload (next/font preloads per instance). Both register the real family name, Archivo, so the browser merges them and every existing font-style: italic still selects the true italic. Nothing else changes. - Archivo normal STAYS preloaded. Un-preloading it was measured: the hero subhead wraps to two lines in the fallback and three in Archivo, so the swap pushed the CTAs and demo down, CLS 0.206 on a 375x812 phone. Local production build, devtools throttling (HTTP/1.1, directional): home LCP 2,429 -> 2,176ms. CLS across the font swap, measured with a layout-shift observer: home 0, docs 0, a blog post with early italics 0.0003. e2e/home-bundle.spec.ts now asserts exactly these two preloads by family and style, that the unpreloaded italic still merges into Archivo, and that mono never falls back to a proportional font. Each was mutation-tested and fails alone on its own regression. --- apps/website/e2e/home-bundle.spec.ts | 74 +++++++++++++++++++++++----- apps/website/src/app/layout.tsx | 62 +++++++++++++++++++++-- 2 files changed, 120 insertions(+), 16 deletions(-) diff --git a/apps/website/e2e/home-bundle.spec.ts b/apps/website/e2e/home-bundle.spec.ts index 1617ba464..b7729f071 100644 --- a/apps/website/e2e/home-bundle.spec.ts +++ b/apps/website/e2e/home-bundle.spec.ts @@ -31,13 +31,15 @@ const REGISTRY_MARKER = 'LangGraph Durable Execution (Python)'; const DOCS_ROUTE = '/docs/langgraph/guides/streaming'; /** - * The fonts the homepage's above-the-fold hero actually renders: Archivo Black - * (the H1), Archivo normal and italic (one next/font instance, so they preload - * together), and JetBrains Mono (the eyebrow and the demo's URL bar). A fifth - * preload is a new High-priority request racing the LCP image on a phone — add - * one only after measuring that it is above the fold. + * The fonts the homepage preloads, identified by family and style. See the + * FONT PRELOADS note in app/layout.tsx for the measurements behind this list: + * on a throttled phone every preloaded font races the hero poster for + * bandwidth, so only faces whose late arrival would visibly hurt are here. + * Archivo italic and JetBrains Mono were measured at -228ms and -224ms of LCP + * each; Archivo normal stays because un-preloading it reflowed the subhead + * (CLS 0.206). Change this list only with a measurement. */ -const MAX_FONT_PRELOADS = 4; +const EXPECTED_PRELOADS = ['Archivo Black normal', 'Archivo normal']; /** * The bodies of the scripts `path` itself requires: the `