ShrinkRay All Articles
Web Performance

Most of Your Font File Is Dead Weight: Ship Only the Glyphs You Render

By ShrinkRay Web Performance
Most of Your Font File Is Dead Weight: Ship Only the Glyphs You Render

Photo by Virginia Marcuzzo on Unsplash

Fonts are one of the few web assets where a single file can carry hundreds of kilobytes of characters your page will never show. Your landing page might render 60 or 70 distinct glyphs. The font file might include Cyrillic, Greek, mathematical symbols, old-style figures, and enough ligatures to set a Victorian novel. The browser does not care about your typographic ambitions. It downloads what you point it at. A 400KB font payload is not a font problem. It is a shipping problem.

Find out what you are actually shipping

Open DevTools, filter Network by Font, and reload with the cache disabled. Note the file count, format, and size. Then check which weights and styles are actually used on the page. A lot of sites load four weights because the design system says so, even though the rendered page uses two. If your CMS lets editors pick from a dozen font styles, count those too. The goal is not to guess. It is to measure. Tools like glyphhanger and fonttools can scan pages or templates and show the character set you really need. Separate static interface copy from user-generated content before you make cuts. A US audience still includes names with accents, currency symbols, curly quotes, and em dashes.

Subset for the alphabet you need

Subsetting takes a font file and keeps only the characters, features, and axes you specify. With fonttools, a basic Latin subset looks like this:

pyftsubset Inter.ttf --output-file=inter-latin.[woff2](https://en.wikipedia.org/wiki/Web_Open_Font_Format) --flavor=woff2 --unicodes=U+0000-00FF,U+2000-206F,U+20A0-20CF --layout-features='kern,liga'

That covers basic Latin, common punctuation, and currency symbols. Add Latin Extended if real content needs it. Do not strip characters that appear in user names, addresses, or product titles unless you are comfortable with the browser falling back per glyph. Test with strings like José, Müller, O'Connor, $19.99, and a curly apostrophe. Subsetting is not about making text worse. It is about not shipping an entire writing system for a page that only needs English plus a few accents.

Split with unicode-range

Instead of one giant file, create a couple of ranges. unicode-range tells the browser which file covers which code points, so it only downloads the ranges the page actually needs. A Latin file and a Latin Extended file are often enough. Keep the list explicit and test it. Do not create 20 tiny files just because you can. Each file has request overhead and cache behavior. Two or three well-chosen ranges usually beat one giant font and beat a pile of micro-files.

Variable fonts need a diet too

A variable font can replace several static weights, which is good. But a full variable font with weight, width, slant, optical size, and custom axes can be larger than two static files. If your design only uses weight 400 and 700, limit the weight axis or ship two static subsets. If you use optical size, keep it, because that is doing real work. The tooling matters here: fonttools varLib.instancer can trim axes and ranges before you subset. Measure the actual WOFF2 output. A subset variable font with a sensible weight range can be a great deal. A full-axis showpiece font is often just a heavier download.

WOFF2 and delivery details

WOFF2 is the default for browsers. Do not ship TTF or OTF files to production unless you have a very specific reason. Serve the correct font/woff2 MIME type. Preload only the primary subset used above the fold. Preloading every font file competes with CSS and JavaScript for bandwidth. Use font-display: swap if you want text visible quickly, but pair it with fallback metrics so the layout does not jump. CSS properties like size-adjust, ascent-override, descent-override, and line-gap-override can make a local fallback match your custom font more closely. For non-critical display fonts, font-display: optional is worth considering.

Accessibility and fallback

Subsetting must not break readability. If a glyph is missing, the browser falls back for that character, which can look inconsistent but should still be readable. Make sure the fallback stack is real and tested. Check the page at 200 percent zoom, in high contrast mode, and with custom fonts blocked. Do not use icon fonts for meaningful content; use inline SVG. Also check the font license. Many licenses allow subsetting, but some do not. Keep the source font and the subsetting script in the repo so the build is reproducible.

Measure the win

Compare before and after with Lighthouse, WebPageTest, and real-user metrics. A 400KB font payload can become 60KB or less without changing the visual design. That is not just a number on a report. It is faster first render on a phone with a spotty connection. Typography can stay beautiful. It just does not need to bring the whole alphabet to a US landing page.