跪拜 Guibai
← Back to the summary

Full Chinese Fonts Cost 1.4s of LCP; a 26.8KB Page Subset Matches System Fonts

I ran an experiment on my landing page: the same HTML, only changing how a Chinese webfont is loaded, in seven versions, using Chrome with simulated Fast 3G (1.6Mbps, 150ms RTT) and 4x CPU slowdown. Each version ran three times and I took the median.

The heaviest element on the page is a main title of 26 characters. With system fonts, it appears in 628ms. With a full Chinese font, it appears in 2032ms. The extra 1.4 seconds only buys a different skeleton for those few dozen characters.

Another set of numbers is more glaring: the 10.89MB font file transmitted 0 bytes in a 10-second observation window on 3G, stuck in loading state the entire time. That is, the 16MB never reached the user, and the user saw the system font the whole time.

Conclusions first, this table is the reason to bookmark.

Six ways to deliver a font, cost differs by 3x

Scheme Font bytes LCP At end of 10s window
System font stack 0 628ms No font request
Full OTF 16.4MB 2032ms Still loading, 0 completed
Full WOFF2 10.89MB 2044ms Still loading, 0 completed
Full WOFF2 + swap 10.89MB 640ms Still loading, font not there
Page subset + swap 26.8KB 640ms Loaded in 1.32s
Subset + preload 26.8KB 716ms Loaded in 1.30s
unicode-range fragments 326KB + 105KB CSS 1788ms 11 slices done, 4.4s

The criteria were set before running: if LCP is more than 300ms slower than system font, it counts as "font is the bottleneck"; if bytes drop by 90% and LCP falls within 300ms, it counts as "subsetting works". I settled the criteria first to avoid picking a convenient story afterwards.

The experiment only changed one variable

The page is a standard landing page: nav bar, 26-character main title, one subtitle, a button, three cards, one footer line. Mobile viewport 390×844, DPR 3, network Fast 3G, CPU 4x slowdown, all requests with Cache-Control: no-store and a random parameter to guarantee cold cache every time.

I recorded FCP, LCP, CLS, actual font bytes transferred, and the time of document.fonts.ready. The main title is the largest text block on the page, so it is the LCP candidate; LCP is essentially "when the title is readable".

Across the seven versions, text, sizes, and structure are identical; the only variable is how the font is loaded.

Where the full font loses

The first bill is arithmetic. Noto Sans SC OTF is 16.4MB; after converting to WOFF2 it's 10.89MB, a format saving of only 32%. Chinese fonts pack thousands of glyphs and cannot be compressed much. 10.89MB is 87Mbit; at 1.6Mbps that takes 54 seconds, and even on a 10Mbps home connection it's nearly 9 seconds. The first screen has about one second of budget, and this file cannot fit even a fraction of it.

The second bill is blocking. The default font-display is auto, and the browser withholds text while waiting for the font. The main title was measured at 2.03 seconds. During those two seconds the page is not "slow" but "incomplete": the subtitle and button are visible, but the title area is empty. The user knows there is content but cannot read it.

The third bill is the swap illusion. Many people (including me) think swapping to font-display: swap solves it. Measured LCP is 640ms, only 12ms slower than system fonts, numbers that look fine. But the 10.89MB still never arrives in the window. When it does arrive, the user has already scrolled away. The font request wasted bandwidth and none of the glyphs were used.

I want to stress this: swap only fixes "invisible text", not "missing font". Metrics looking good and requirements being met are two different things.

How the 26KB subset was made

After deduplication, this page has 108 characters, including numbers, punctuation, and symbols like book title marks. Encoding only those 108 characters produced 26.8KB, which is 0.25% of the full WOFF2, with an LCP of 640ms, matching system fonts.

Export and subsetting take two commands:

# 1) Deduplicate the page's characters into corpus.txt
node -e "const t=require('fs').readFileSync('index.html','utf8').replace(/<[^>]+>/g,'');require('fs').writeFileSync('corpus.txt',[...new Set(t)].join(''))"

# 2) Subset and convert to WOFF2
pyftsubset NotoSansSC-Regular.otf --text-file=corpus.txt \
  --flavor=woff2 --layout-features='*' --no-hinting \
  --output-file=page.woff2

Two things to watch.

First, the corpus must be exported from the actual page text, not guessed from "common characters". Numbers, units, full-width punctuation, and symbols like "℃", "·", "—" are the easiest to miss. Missing a character doesn't throw an error; it silently falls back to a system font, and when two characters sit side by side you notice it as a bug.

Second, backend-style pages get text from a database and will always have new characters. In that case, don't chase the 26KB extreme; build a subset from the GB2312 level-one character set. I measured 3,755 Chinese characters at 1,050KB, and level-one plus level-two (6,763 characters) at 1,900KB. Add a full system font stack as a fallback; new characters will look different but the layout won't collapse.

@font-face {
  font-family: 'NSC';
  src: url('page.woff2') format('woff2');
  font-display: swap;
}
body {
  font-family: 'NSC', -apple-system, BlinkMacSystemFont,
    'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
}

Give the font file a content hash in its name, cache for a year, so only releases that change the font incur a download cost; everything else is cache hits.

Two counterintuitive pitfalls

Preload is a negative optimization on this page. Intuitively, adding <link rel="preload"> lets the browser discover the font earlier and should be faster. Measured: 716ms, a full 88ms slower than the subset version without preload. The reason is simple: the first screen has only one critical chain (HTML to CSS), and preload jumps to fetch the font in HTML, pushing first render back. Preload is worth it only when the font itself is very large and is indeed the replacement for the LCP element.

Unicode-range splitting is not free lunch. The official @fontsource approach splits a font family into 102 fragments, each declaring the range of characters it covers; the browser downloads only the matching fragments. That sounds like the standard answer for "on-demand loading". Measured on this page: 11 fragments matched, 326KB total, and it took 4.4 seconds for all fonts to appear. FCP was 1788ms, 1.16 seconds slower than system fonts. The root cause is the 102 @font-face rules themselves, which make up 105KB of CSS and are render-blocking.

Fragmenting suits sites that share one font across many pages with widely varying text. For a single page, it is the worst of the three options.

Pre-launch checklist

Final thoughts

The size of a Chinese font is not an "optimization item", it's a design decision. When you receive a full font file, ask first: how many characters will this page actually use?

I've left the measured font data and this checklist in the project. How large is your online Chinese font file? Leave the byte count in the comments, and I'll estimate its arrival time on 3G. For anything over 1MB, I'll probably advise you not to ship it.

Comments

Top 1 of 2 from juejin.cn, machine-translated. The original thread is authoritative.

组合搭配函数

This real-world test is really solid; after running seven versions, the full font dragging the title by two seconds makes you shake your head. Subsetting is indeed a must-have for Chinese sites; the time saved is all tangible.

kyriewen

Like.