Web Font Loading Optimizer
Paste your @font-face rules or page head, see what slows text or shifts layout, get clean woff2 rules with preloads, and measure a font file to build a matched fallback.
Funziona nel tuo browser. I tuoi file non lasciano mai il dispositivo. Scopri come verificarlo
…
Come si usa
- 1Paste font CSS
Paste your @font-face rules and the link tags from the page head.
- 2Read the audit
Check each flagged rule, preload and Google Fonts link in the Audit tab.
- 3Build rules
Choose font-display and copy the optimised @font-face rules.
- 4Add preloads
Copy only the one or two preload tags used above the fold.
- 5Measure the font
In Fallback metrics, open the woff2 or ttf file and choose the local fallback.
- 6Use the fallback
Copy the fallback rule and font-family stack and compare the preview.
Informazioni su questo strumento
Web fonts affect speed in two ways. While a font downloads, text can stay invisible, which delays Largest Contentful Paint when the biggest element is a heading. When the font arrives and replaces the fallback, words change width and lines rewrap, which adds Cumulative Layout Shift. This optimizer looks at the CSS and link tags that load your fonts and checks each rule. It reads every @font-face with its family, weight, style, font-display, unicode-range and sources, and every link tag in the head. It flags missing font-display or the block and auto values that hide text, a first source that is not woff2, old EOT and SVG sources, local() sources, many static weights where a variable font would be lighter, missing unicode-range, preload links without crossorigin or as=font, too many preloads, Google Fonts links without a display parameter or a preconnect, and fonts loaded through @import. The build tab writes clean rules with woff2 first, your chosen font-display and the original unicode-range, plus preload tags. The fallback tab builds a size-adjusted local fallback.
Matched fallbacks
A fallback that is the same width as the web font makes the swap almost invisible. CSS lets you adjust a local font with size-adjust, ascent-override, descent-override and line-gap-override. Open your font file and the page loads it into the browser, measures the average character width of a sample sentence in it and in the chosen local font, and reads the ascent and descent the browser uses. From those it computes size-adjust as the width ratio and divides the vertical metrics by it, the same method Next.js and Capsize use. You can also type metrics by hand, as font units divided by units per em. A live preview shows the adjusted fallback next to the plain local font.
Choosing font-display
swap shows text at once in the fallback and swaps when the font loads; pair it with a matched fallback to keep the shift small. optional gives the font a very short window and keeps the fallback if it misses, which removes the shift entirely but can show the fallback on slow first visits. fallback sits between the two.
Limits
Metrics measured on your device depend on that device's copy of the local font; Arial on Windows and macOS match closely, but Android has no Arial, so a second fallback such as Roboto may need its own rule. Line gap cannot be read by measuring and defaults to zero. The tool does not convert or subset font files; use a font subsetter for that. It is not a licence check; make sure your font licence allows self-hosting.
Esempio svolto
The sample head loads Inter from the site and Merriweather from Google Fonts. The audit finds 8 issues: Inter 400 has no font-display and lists a truetype file before its woff2, Inter 700 uses font-display: block, which can hide text for up to 3 seconds, and still lists an EOT file. The preload of inter-400.woff2 lacks crossorigin, so the browser would fetch the font twice, and the Google Fonts link has no display parameter and no preconnect. The build tab outputs two rules with only woff2 sources and font-display: swap. With Inter metrics of ascent 0.969, descent 0.242 and an average width of 0.52 against Arial at 0.5, the fallback gets size-adjust 104%, ascent-override 93.17% and descent-override 23.27%.
In breve
- Categoria: Sviluppo e dati
- Funziona nel browser, senza registrazione né caricamento.
- Le informazioni che inserisci restano sul tuo dispositivo.
- Disponibile in inglese.
- Contenuto rivisto l'ultima volta il:
- Fonte ufficiale: web.dev: best practices for fonts, and CSS Fonts Module Level 5 (size-adjust, ascent-override)
Domande frequenti
Should I use swap or optional?
Use swap for brand fonts that must appear, with a matched fallback to limit the shift. Use optional for body text when speed and stability matter more than the exact typeface on a first visit.
Why does a font preload need crossorigin?
Fonts are always fetched in anonymous CORS mode. A preload without crossorigin uses a different mode, so the browser cannot reuse it and downloads the font a second time.
Which formats do I still need?
woff2 is supported by every current browser. woff can stay as a second source for very old browsers; TTF, OTF, EOT and SVG fonts are not needed on the web.
How is size-adjust calculated?
It is the web font's average character width divided by the fallback's. Ascent, descent and line gap are then divided by the same factor so line heights match.
Does it subset my fonts?
No. It keeps your unicode-range values and tells you when splitting by range would help, but subsetting files needs a separate tool.
Is my font file uploaded?
No. It is loaded into this browser tab with the FontFace API only to measure it, and nothing leaves your device.
