skip to content

Your LCP element is a headline set in a self-hosted web font. How do CSS font-display: block and font-display: swap move Largest Contentful Paint and Cumulative Layout Shift in opposite directions, and how do you decide between them?

level: middleimportance: should knowfreq 48%

answer

  1. invisible text is not a contentful paint
  2. swap buys the paint, pays in movement
  3. CLS has no time cutoff
  4. the shift is a metrics mismatch
  5. warm cache hides both symptoms

basics

~20 s

With CSS font-display: block the headline stays invisible until the font arrives, so LCP waits for the font. With swap it paints immediately in a fallback, giving an early LCP but a reflow when the real font arrives, which lands in CLS.

solid answer

~50 s

They trade one vital for the other. `font-display: block` hides the text while the font is still loading, and unpainted text is not a contentful paint — so your LCP timestamp is effectively pinned to the font's download, and a slow font makes a fast page score badly. `font-display: swap` paints the headline in the fallback face straight away, which usually gives a much earlier LCP; the cost is that when the web font arrives, glyph metrics change, the headline re-lays-out, and everything below it moves — a layout shift that counts toward CLS with no time cutoff. So the decision is: for large above-the-fold text, swap plus a metrics-matched fallback usually wins both, because a well-matched fallback shrinks the shift toward zero. Reserve block-like behaviour for cases where showing the wrong face is genuinely unacceptable, such as an icon font.

go deeper

for a junior

Know that a web font arriving late either hides text or changes how it looks mid-load, and that both are visible to users. Be able to say which of the two situations you have seen on a real site.

for a middle

Explain the mechanism in both directions: unpainted text produces no contentful paint, so LCP waits; re-typeset text changes block height, so content below moves and CLS grows. Name the metric each option taxes.

for a senior

Demonstrate that you would not accept the tradeoff as given — argue from field data which vital is actually suffering, then close the gap with fallback metric matching and faster font delivery rather than flipping a descriptor and hoping.

for a principal

Own it as a system property: which fonts a site is allowed to load, who approves a new weight, and whether the design system guarantees a metric-matched fallback so no individual team has to relitigate this per page.

## Why a font choice shows up in two different metrics Web fonts sit exactly on the seam between the two loading vitals. Largest Contentful Paint asks *when did the biggest thing paint*; Cumulative Layout Shift asks *how much did already-painted content move afterwards*. A font that arrives late can either delay the paint or move it after the fact, and the `font-display` descriptor is what decides which of the two you pay. The crucial fact for LCP is that **text that is not painted is not a contentful paint**. If the browser is deliberately rendering a headline invisibly while it waits for a font, that element contributes nothing to LCP yet. Whatever else is on screen becomes the current LCP candidate, and when the text finally appears — often as the largest element on the page — a new, much later LCP is recorded. The crucial fact for CLS is that **layout shifts are collected for the whole page lifetime**, not just the first few seconds. A font swapping in at four seconds still counts. CLS scores the shifts in session windows and reports the worst one, and shifts within roughly half a second of a user interaction are excluded as user-initiated — but nothing excuses a shift simply for being late. ## What each choice does to the numbers **Blocking behaviour.** The headline is laid out but painted invisibly while the font loads. LCP for that element cannot be recorded until the font arrives or the browser gives up and uses the fallback. On a fast connection this looks fine; at the 75th percentile on mobile, where the font may be a third-party origin needing a fresh connection, your LCP inherits the font's entire critical path. The upside is that the user never sees two different typefaces, so this path contributes essentially no font-induced layout shift. **Swapping behaviour.** The headline paints immediately using the next font in the `font-family` stack. LCP is recorded early, on the fallback paint, and is usually excellent. Then the web font arrives, the text is re-rendered with different glyph advance widths, x-height and line height, and the block can change height — wrapping from three lines to two, or vice versa. Everything below it translates, and that translation is scored into CLS. If the swap also grows the text block substantially, the browser may additionally report a new, later LCP candidate for the same element. ## The move that gets you both The framing "pick your poison" is the mediocre answer. The strong answer is that the swap-induced shift is a *metrics mismatch* problem, not an inevitability: the shift exists because the fallback and the web font occupy different amounts of space. Closing that gap — choosing a fallback whose metrics are close, and tuning the fallback's metrics so the two typeset nearly identically — collapses the shift toward zero while keeping the early paint. Then swap is simply better on both vitals, and you have no tradeoff left to argue about. A second lever is making the font arrive before the deadline matters at all: self-host it on the document origin so there is no extra connection, ship only the weights and glyph ranges the page uses, and let the critical text font be discovered as early as possible. A font that lands in 200 ms makes the whole block-versus-swap argument academic. ## Diagnosing which one is actually hurting you Field data settles it. If LCP is poor and the LCP element is a text block, look at whether the text is being withheld: a large gap between first paint and LCP with no image in the picture is the signature. If CLS is poor and the shifts cluster shortly after page load with text-heavy regions moving, the font swap is the prime suspect — especially when the shift value is small but repeated across several sections. A classic false comfort is the local test. On a warm cache the font is instant, so neither the invisible-text delay nor the swap reflow reproduces. Both symptoms only appear on a cold cache and a slow connection, which is precisely the population that dominates a 75th-percentile field score. ## Where blocking still wins Some content is meaningless in a fallback. Icon fonts render as random letters, and a wordmark in the wrong face is a brand defect rather than a temporary inconvenience. For those, holding the paint is correct — but the right response is usually to remove the dependency instead: icons belong in SVG, and a wordmark belongs in an image, neither of which puts a font download on the critical path of your headline. ## The judgment to show Say explicitly which metric each option taxes, name the mechanism (unpainted text is not a paint; re-typeset text moves what is below it), then refuse the false dilemma by pointing at fallback metrics and font delivery. That progression — tradeoff, mechanism, then the move that dissolves the tradeoff — is what separates a memorized answer from an operational one.

  • Why does the swap-induced shift still count if it happens four seconds after load?
    CLS accumulates for the entire page lifetime, not a fixed startup window. It groups shifts into session windows and reports the worst window's score, and only shifts occurring shortly after a user interaction are excused. A font arriving late is not user-initiated, so its reflow is scored in full.
  • If the fallback and the web font are visually different sizes, which direction does the shift usually go?
    Usually the block gets shorter when a narrower or smaller-x-height web font replaces a wide system fallback, so content below moves up; a wider web font does the reverse. Either direction scores in CLS — the metric measures displacement, not whether things grew or shrank.
  • Does a font-caused reflow ever change which element is reported as the LCP element?
    It can. LCP tracks the largest contentful paint until the first user interaction, so if the text block paints late or grows substantially when the real font lands, a new and later candidate can be reported. That is why a font problem sometimes surfaces as a mysterious second LCP entry.

saying these in an interview costs you the question

  • Claims text hidden while a font loads still counts for LCP
  • Thinks CLS stops accumulating after the first few seconds
  • Treats the swap reflow as unavoidable rather than a metrics mismatch
  • Tests on a warm cache and concludes there is no problem
  • Says fonts only ever affect CLS, never LCP

context