Skip to content
Skills Library
Programming · Building & coding

font-loading

/font-loading

Load web fonts without layout shift by subsetting the file, setting font-display, preloading first-paint weights, and matching fallback metrics. Use when custom fonts cause invisible text, a flash of restyle, or a CLS spike.

Repository
AI-SKILLS ↗
Licence
MIT
Last repository change
05.09.2026

Assessment and security

90/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content25 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 05.09.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Load web fonts without layout shift by subsetting the file, setting font-display, preloading first-paint weights, and matching fallback metrics. Use when custom fonts cause invisible text, a flash of restyle, or a CLS spike.

Original author description

Load web fonts without layout shift by subsetting the file, setting font-display, preloading first-paint weights, and matching fallback metrics. Use when custom fonts cause invisible text, a flash of restyle, or a CLS spike.

How it works

  1. Method
  2. Signals
  3. Boundaries
Original SKILL.md headings · 46 lines, 357 words
SKILL.md preview
---
name: font-loading
description: Load web fonts without layout shift by subsetting the file, setting font-display, preloading first-paint weights, and matching fallback metrics. Use when custom fonts cause invisible text, a flash of restyle, or a CLS spike.
---

# Font loading

Web fonts arrive after the HTML and CSS that reference them, so the browser must
choose: hide the text until the font loads, or show a fallback and reflow when
the real font swaps in. The first flashes invisible text, the second jumps the
layout. Load fonts so text is readable immediately and nothing moves when the
swap happens.

## Method

1. **Set `font-display` in every `@font-face`.** Use `swap` to show fallback
   text at once and swap later, or `optional` to skip the swap on slow
   connections. Never leave the default `block`, which hides text for the
   whole fetch.
2. **Preload the weights first paint needs.** Add
   `<link rel="preload" as="font" type="font/woff2" crossorigin>` for the one or
   two faces above the fold so the fetch starts before the CSS is even parsed.
3. **Subset to the characters you actually use.** Strip unused glyphs and
   scripts with `glyphhanger` or `pyftsubset`; a Latin-only subset can be a
   fraction of the full file. Split by script with `unicode-range` so only the
   needed subsets download.
4. **Ship woff2 and nothing else.** woff2 is the smallest format and universally
   supported. Drop woff, ttf, and eot fallbacks unless you must serve ancient
   browsers: fewer formats mean smaller CSS and one fetch per face.
5. **Match fallback metrics to kill the swap shift.** Set `size-adjust`,
   `ascent-override`, and `descent-override` on a fallback `@font-face`,
   or use a tool like Fontaine, so the fallback fills the same space and
   the swap does not move text.
6. **Self-host instead of a third-party origin.** Serving fonts from your own
   domain removes a cross-origin connection and DNS lookup from the critical
   path and avoids a render-blocking request to a font CDN.

## Signals

- Is text visible during the font load rather than blank?
- Are first-paint fonts preloaded, so the fetch is not discovered late?
- Does the shipped file carry only the glyphs the site uses?
- Does the fallback-to-webfont swap leave the layout unmoved?

## Boundaries

The layout-shift metric this feeds is web-vitals' CLS; right-sizing images that
also shift layout is image-optimization. Variable-font axes and icon fonts carry
separate tradeoffs. Delivery caching defers to cdn-strategy.

Versions

RepositoryScoreLicence
This page · Amey-Thakur/AI-SKILLS90MIT
thedaviddias/front-end-checklist100MIT

Database snapshot: 13.11.2026 · package version 0bc4e7edf6d7 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 90fe-fonts
    Loads web fonts fast and without layout shift - self-hosted WOFF2, font-display, a correct preload with crossorigin, subsetting and unicode-range, variable fonts, metric-matched fallbacks, system font stacks, and next/font or @nuxt/fonts. Use when adding or changing fonts, when…
  • 100font-loading-stinger
    Fix web font loading performance. Use for FOIT/FOUT, preload, subsetting, metric-matched fallbacks, or font-swap CLS. Read README.md for the guide map.
  • 100fonts
    Font management knowledge base - next/font, self-hosting, download, licensing, variable fonts. Use when managing fonts in Next.js, setting up self-hosted fonts, or optimizing font loading performance.
  • 100nextjs-optimization
    Optimize images, fonts, scripts, and metadata for Next.js performance and Core Web Vitals. Use when configuring next/image for LCP, next/font for zero layout shift, next/script loading strategies, or generateMetadata for SEO.
  • 100fonts
    Configures web fonts through Astro's Fonts API and picks type pairings — provider, weights, preloading, and the Tailwind wiring. Use for "add Google Fonts", "use custom fonts", "change the typography", "pick a font pairing", "what font should I use", "optimize font loading", or…
  • 100web-vitals-analyzer
    Analyze and optimize Core Web Vitals (LCP, CLS, INP) and frontend performance. Use when a user asks to improve page speed, fix layout shifts, reduce loading times, analyze Lighthouse reports, optimize bundle size, or improve Google PageSpeed scores. Covers image optimization,…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.