Frontend Developer Interview Question

How do you load web fonts without causing layout shift or hiding text?

What the interviewer is probing, how to structure your answer, and a spoken example you can adapt.

Quick answer

Self host the font, preload the one file needed for first paint, and use font display swap so text is visible immediately. Then remove the shift by matching the fallback metrics with size adjust, ascent override and descent override, or by using a generated fallback face. Subset the font to the characters you actually use, ship woff2 only, and avoid loading multiple weights when variable fonts cover the range.

Why interviewers ask this

Fonts are the most common cause of layout shift and one of the easiest wins in a performance review. The interviewer is checking whether you know why the shift happens, which is a metric mismatch between the fallback and the real face, rather than just reciting font display swap. Knowing about self hosting and preloading also shows you understand third party origins cost an extra connection before the font is even discovered.

How to structure your answer

  • Explain why the shift happens: fallback metrics differ from the real face.
  • Give the loading strategy: self host, preload, woff2, subset.
  • Cover the display value tradeoff between blank text and a swap.
  • Finish with metric overrides to make the swap unnoticeable.

Example answer

Spoken example, first person

The shift happens because the fallback font has different metrics, so when the real font arrives every line re flows and everything below it moves. So there are two problems to fix: when the text appears, and how much it moves when it changes. For the first, I self host the font, preload only the file needed for the initial view, and use font display swap so no one stares at a blank block of text on a slow connection. For the second, I override the fallback metrics, size adjust plus ascent and descent overrides on a local fallback face, so the fallback occupies almost exactly the same space and the swap is barely visible. Beyond that it is hygiene: woff2 only, subset to the character set actually used, and a variable font instead of four static weights. On one site that was pulling three weights from a third party origin, moving to a self hosted subset variable font cut about 180 kilobytes and took CLS from roughly 0.18 to under 0.02.

Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.

See how it works

Follow-up questions to expect

  • What is the difference between font display swap, optional and fallback?
  • How would you measure the layout shift a font is causing?
  • When is a system font stack the better answer?

Related frontend developer questions

Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.

Predict my questions

Rehearse the hard questions before they are asked

Practise with a live copilot, then walk in ready. A $29 Session Pass gets you through the interview with no subscription and no lock-in.

Get GhostPilot