WebTech1223411 logo WebTech1223411Web tech, read closely
Browsers

How Web Font Loading Works and How to Avoid Invisible Text

The page has loaded, the layout is there, but the headline and body text are blank for a second or two before they suddenly appear. Or the text shows up in Arial, then jumps into your brand font and shoves every paragraph down by a line.

A developer's monitor showing a browser network panel filtered to font files beside a web page with large headline type, a keyboard in front

The page has loaded, the layout is there, but the headline and body text are blank for a second or two before they suddenly appear. Or the text shows up in Arial, then jumps into your brand font and shoves every paragraph down by a line. Both problems come from the same place: how the browser handles web font loading, and when it decides to wait for a font file versus painting with whatever it already has.

Once you know the order of events, both the invisible text and the layout jump are fixable with a few lines of CSS and one extra tag in the head. This article walks through what the browser actually does and which settings to choose.

How the browser discovers a web font

A font file is not downloaded when the browser reads your @font-face rule. That surprises a lot of developers. The rule only registers the font as available. The download starts when the browser has built both the DOM and the CSSOM, matched styles to elements, and found at least one visible piece of text that needs that font.

In practice the sequence looks like this.

  1. The HTML arrives and the parser starts building the DOM.
  2. The browser finds the stylesheet, downloads and parses it. CSS is render-blocking, so nothing paints yet.
  3. The browser computes styles and realises a heading uses "Inter" at weight 700.
  4. Only now does it request the matching font file.
  5. While that request is in flight, the text has to be painted somehow, or not at all.

That means the font request starts late, after at least two round trips. On a mobile connection with 150 ms latency, it is easy for a font to arrive 600 to 900 ms after the first paint. If you want the bigger picture of that pipeline, our walkthrough of what happens between typing a URL and seeing a page covers each stage.

Block, swap and fallback: the font-display periods

The browser splits the waiting time into periods. During the block period, text using the font is rendered invisible. During the swap period, the browser paints a fallback font and swaps in the web font when it arrives. After the swap period ends, it keeps the fallback for the rest of the page view.

The font-display descriptor inside @font-face sets the length of those periods.

ValueBlock periodSwap periodGood for
autoBrowser default, usually about 3 sUnlimitedRarely the right choice
blockAbout 3 sUnlimitedIcon fonts where fallback glyphs are meaningless
swapClose to 0UnlimitedHeadings and brand text
fallbackAbout 100 msAbout 3 sBody text on content sites
optionalAbout 100 msNoneBody text where stability matters most

The "invisible text" effect, often called FOIT, is the block period in action. On a slow connection, the default can leave a page blank for three full seconds. The "flash of unstyled text", FOUT, is the swap period doing its job, which is usually the lesser evil.

How to start web font loading earlier

Since the browser discovers fonts late, the biggest win is telling it about them sooner. Add a preload link tag in the head for the one or two font files used above the fold, with as="font", the correct type such as font/woff2, and the crossorigin attribute. That last one is required even when the font is on your own domain, because fonts are always fetched in CORS mode. Without it, the browser downloads the file twice.

A few other habits reduce the delay further.

  • Serve WOFF2 only. Every current browser supports it, and it is roughly 30 percent smaller than WOFF.
  • Self-host. A font on a third-party domain costs an extra DNS lookup, connection and TLS handshake. On mobile that can add 300 ms.
  • Subset. A full Latin font with every weight can be 200 KB. A subset with only the characters your site uses is often under 25 KB.
  • Use a variable font when you need three or more weights. One file replaces several.
  • Cache aggressively. Font files rarely change, so give them long cache lifetimes with fingerprinted filenames. Our guide to how browser caching decides what reloads explains the headers.

Why "always use font-display: swap" is not the whole answer

Most performance audits recommend font-display: swap for every font, and many teams apply it everywhere. It does remove invisible text. But on body copy it often trades one problem for another.

With swap, the browser paints the fallback font, then replaces it whenever the web font arrives, even five seconds later. If the fallback has different letter widths or line height, every paragraph reflows. Buttons move under the reader's finger, the reader loses their place, and the page scores worse on Cumulative Layout Shift. On a long article I measured a CLS of 0.18 from the font swap alone, well past the 0.1 threshold.

For body text, fallback or optional is frequently the better choice. With optional, a visitor on a slow first load may never see your brand font, but the page is stable, and on their next visit the font is cached and appears immediately. Keep swap for headings and short brand text, where the font carries meaning and the shift is small.

Match the fallback to reduce the shift

Whatever value you pick, you can shrink the jump by tuning the fallback. Define a second @font-face that points at a local system font and adjust it with size-adjust, ascent-override, descent-override and line-gap-override until its metrics match your web font. Done well, the swap becomes almost invisible: the letters change shape but nothing moves. Several open source tools calculate these values for popular fonts automatically.

Testing font loading properly

Fonts often look fine on a developer machine because they are already cached and the connection is fast. To see what visitors see, open DevTools, disable the cache, throttle the network to "Slow 4G" and reload.

  • In the Network panel, filter by Font and check when each request starts relative to the HTML. A late start means preload is missing or not matching.
  • In the Performance panel, look for layout shift markers around the moment the font arrives.
  • Check the same page in Safari and Firefox. They handle font timeouts slightly differently, which is one of the quieter reasons a site works in Chrome but breaks in Safari.

Frequently asked questions

Why does my text disappear while web fonts load?

The browser is in the font's block period, rendering text invisibly while it waits for the file. By default that can last up to three seconds. Setting font-display to swap, fallback or optional shortens or removes the block period.

Should I preload all my web fonts?

No. Preload only the one or two files needed for text visible on first screen. Preloading every weight competes with critical CSS and images for bandwidth and can slow the first paint instead of speeding it up.

Does font-display: swap cause layout shift?

It can. When the web font replaces a fallback with different metrics, text reflows and elements move. Using fallback metric overrides, or choosing optional for body text, keeps the layout stable.

MC
Maren Castellanos

Maren worked in cross-browser QA before editing, and knows the DevTools Network tab better than most people know their inbox. She writes about how browsers load and render pages and about the tools that show what is really happening.

More posts by Maren

More in Browsers

01doorganico 084goad 3hot8 4465456 after5internprogram ahandfulofblessings ahmadpc ahomcybersecurity allodialresources annodex antiquesandperiodcollectibles aotc asianworldkashmir beedlectrics bloggertemplatefree bluefeatheragency bodyweightsolution campaign08blog carfixadvisor catstreetcollective cbstvsports cnfanspurchasing committeeof500yearsofdignityandresistance covertopsdjs cs-kaiyuangame cuestacomunicaciontotal cxoutlet dancebetgame deskgearhub destinyvillastay detectmagazine di33 diamondsteelbuildings donmo dyanadropship emarsysfinance emimattl escapechan eskitarih evautoplay everythingweddings-orlando farmzone feedviewerapp foxstudiosscratch gamevui123 gleasongrade greetingsday hacklabasu haskell iw-kaiyun jagoanproperti jilidskripsi joltbusinessfinance juegodepokergratis juegospucca kaeru-festival latestmehndidesigns lestanzediottaviano litemagazines localcommunityhero lustrsazan mariashebets menswheels newwebstechs1 nikkit ootheday oxigenvpn plurfitness prefetial probudgetcarpetcleaning psychicmrsmartin pyaten qvantor rejoignezlogis rexzbot riselayouts ruchin rwxqsgd5 sakaltime shibiaowang shop-bot skrtips spotlesshaven strcoding tetapatrium topselller uneplanteartificielle vipertechcr wo-kygaming yamaha-mekar yeknava yoybuysheets zenunwa yamaha-mekar jilidskripsi ankertoto ankertoto ankertoto