Skip to content
SEO Optimizer is live, Audit on page SEO and AI-search readiness. Try it free

How to Fix 'Ensure Text Remains Visible During Webfont Load'

"Ensure text remains visible during webfont load" is a performance warning that appears when your page hides text until a custom font has downloaded. On a slow connection, visitors stare at a blank area where your heading should be, sometimes for several seconds. This is called a flash of invisible text (FOIT). The fix is mostly one CSS property, font-display, plus a few changes to how fonts are loaded so the swap is quick and does not shift the layout.

Why Text Goes Invisible

When a browser needs a web font that is not downloaded yet, most browsers hide the text for up to about three seconds while they wait, then fall back to a system font. The font-display descriptor in @font-face controls this behavior:

font-display valueWhat happensGood for
auto / blockText hidden for up to about 3 seconds, then fallbackIcon fonts only
swapFallback text shows at once, swaps when the font arrivesMost body and heading text
fallbackVery short hidden period, short window to swap, otherwise keeps the fallbackBody text where late swaps are distracting
optionalUses the font only if it is ready almost immediatelyBest for avoiding layout shift on repeat visits

Step 1: Add font-display: swap

fonts.cssSelf-hosted font with font-display
@font-face {
  font-family: "Inter";
  src: url("/fonts/inter-var.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

Google Fonts: add &display=swap to the stylesheet URL. Recent Google Fonts embed codes include it already, but older themes often do not.

next.config / layout.tsxNext.js next/font with font-display
import { Inter } from "next/font/google";

// next/font defaults to swap. Setting it explicitly documents the choice.
const inter = Inter({ subsets: ["latin"], display: "swap" });

If you use a CSS framework or theme that loads fonts for you, search the built CSS for @font-face rules without font-display. Icon fonts are the one case where block can make sense, because showing fallback letters in place of icons looks broken.

Step 2: Preload the One or Two Fonts You Need First

index.htmlPreload the main font file
<link rel="preload" href="/fonts/inter-var.woff2" as="font" type="font/woff2" crossorigin>

Preloading tells the browser to start downloading the font before it finds it in the CSS, so the swap happens sooner. Preload only the font used above the fold, usually the main text or heading font. Preloading many fonts competes with the hero image and can make LCP worse. The crossorigin attribute is required for fonts, even on your own domain.

Step 3: Load Fewer and Smaller Font Files

  • Use WOFF2 only. Every current browser supports it, and it is the smallest format.
  • Use a variable font instead of separate files for each weight.
  • Subset to the character sets you use, such as Latin only.
  • Self-host instead of loading from a third-party domain, which avoids an extra connection.
  • Drop unused weights and styles. Many sites load six or eight font files and use three.

Step 4: Stop the Swap From Shifting the Layout

With font-display: swap, text appears immediately in a fallback font and then switches. If the two fonts have different widths and heights, the text reflows and pushes content around, which counts toward Cumulative Layout Shift. Match the fallback to the web font with metric overrides:

fonts.cssA fallback font tuned to match the web font
@font-face {
  font-family: "Inter Fallback";
  src: local("Arial");
  size-adjust: 107%;
  ascent-override: 90%;
  descent-override: 22%;
  line-gap-override: 0%;
}
body { font-family: "Inter", "Inter Fallback", sans-serif; }

Next.js next/font generates this fallback for you. Tools such as Fontaine or Capsize calculate the values for other setups. See how to fix CLS for other causes of layout shift.

Step 5: Check the Result

Run a website audit to confirm the "ensure text remains visible during webfont load" warning is gone and that LCP and CLS did not get worse. If your site's code is on GitHub and you have connected the repository, the audit can find the file that loads the font, add font-display: swap to @font-face rules or display: "swap" to next/font calls, and open a pull request for you to review. For the related warnings, see how to fix render-blocking resources and how to fix LCP.

FAQ

Questions fréquentes

Your page hides text while a custom font downloads. Visitors see blank space instead of text until the font arrives or the browser gives up and shows a fallback.

It tells the browser to show text in a fallback font immediately and swap to the web font once it has loaded, instead of hiding the text while waiting.

It can, if the fallback font has different metrics. Use size-adjust and the ascent, descent and line-gap overrides, or next/font, to make the fallback match.

No. Preload only the one or two fonts used above the fold. Preloading many fonts competes with more important resources such as the hero image.

optional avoids layout shift by only using the web font if it is ready almost immediately, so first-time visitors may see the fallback font. It is a good choice when layout stability matters more than brand typography on first load.

Gratuit - aucune inscription requise

Check this on your own site

Run a free scan and see exactly where you stand - no sign-up required.

Lancer l'audit gratuit