Home » Wordpress » Fix for “Ensure text remains visible during webfont load” in GeneratePress

Fix for “Ensure text remains visible during webfont load” in GeneratePress

If you test your website’s speed by using Google PageSpeed Insight tool, you may come across this common warning about possible delays: “Ensure text remains visible during webfont load. Leverage the font-display CSS feature to ensure test is user-visible while webfonts are loading”

The warning section will also show you the font URLs as you will see in the screenshot below.

Ensure text remains visible during webfont load error

If you are using a caching and performance testing plugin like Humminbird, you may see this warning in their reports as well:

"Ensure text remains visible during webfont load" in Hummingbird

Basically, this warning says that there is no alternative font specified if it takes too long to fetch the actual font you want to use. Google has a wealth of information about this warning on this page.

Solution for “Ensure text remains visible during webfont load” in GeneratePress

If you are using GeneratePress theme, you can easily fix this warning by following the steps below.

  1. In WordPress admin panel, go to Appearance > Theme Editor
  2. From the list “Theme Files” on the right side, select functions.php
  3. Add the code below to the end of the file and click “Update File
add_filter( 'generate_google_font_display', function() {
    return 'swap';
} );

If you update your theme in the future, make sure to add these lines again after the update.

Ned Sahin

Blogger for 20 years. Former Microsoft Engineer. Author of six books. I love creating helpful content and sharing with the world. Reach me out for any questions or feedback.

Leave a Comment