← All posts

WORLDLINE 09 · Site and log go live

Two font files instead of one, and 0.6s off first paint

Ship the words you need now. The rest can take a later train.

A full Noto Sans SC runs about 10 MB. We keep the 984 characters this site actually uses and split them across two files.

  1. 01 Half the trap is fonts
  2. 02 Split into two files
  3. 03 Complementary ranges
  4. 04 Subsetting is a script
  5. 05 The result

01 Half the trap is fonts

On a Chinese site, fonts are where performance goes to die. The variable source is 30 MB, a full woff2 still lands around 10 MB. Nobody ships that. The trap is that a subsetted font is usually still one big file.

02 Split into two files

So we split it in two. The first-screen file holds only the site name, the nav, the H1, the subtitle and the button labels: 261 characters, 70.7 KB, preloaded from the head so it arrives with the HTML. The full file scans every Chinese string under src, comes to 984 characters and 343 KB, and only downloads when a page actually renders one of them.

03 Complementary ranges

Both files need unicode-range, and the ranges have to be complementary. Skip that and the browser matches against the first file, misses, falls back to a system font: half the line in Noto, half in Microsoft YaHei, weights and widths visibly disagreeing.

04 Subsetting is a script

Subsetting is not a one-off. Change a line of copy and a word can drop out. So the font is a script in this repo: scan the source, collect characters, pyftsubset, emit @font-face, then verify nothing is missing. Three seconds after a copy edit.

05 The result

On 4G throttling: FCP 0.81s, LCP 1.41s, 414 KB of Chinese font in total, and only 70.7 KB blocking first paint.