Asked 3 years ago
10 Feb 2021
Views 896
Cimb

Cimb posted

How to solve error Ensure text remains visible during webfont load - Google PageSpeed Insights

in google PageSpeed Insights test tool,
i am getting this error


Ensure text remains visible during webfont load

Leverage the font-display CSS feature to ensure text is user-visible while webfonts are loading.


URL

…fonts/fl-chapps.woff(massjeans-online.de)
Potential Savings : 3,000 ms
…v13/0ybgGDoxx….woff2(fonts.gstatic.com)
Potential Savings : 10 ms
…fonts/MaterialI….woff2(massjeans-online.de)
Potential Savings:1,320 ms
…fonts/fontawesome-webfont.woff2?v=4.5.0(massjeans-online.de)
Potential Savings : 1,580 ms

hanuman

hanuman
answered Apr 25 '23 00:00

"Ensure text remains visible during webfont load" is a warning message shown by Google PageSpeed Insights. It suggests that the text on a website should remain visible while the web fonts are being loaded. Here are some ways to address this warning message:

1.Use system fonts: Using system fonts in place of web fonts can eliminate this warning as system fonts are already installed on the user's device and do not require a download.

2.Use font-display property: You can use the font-display property in CSS to define how the browser should handle the text while the font is being loaded. For example, you can use the font-display: swap property to display the text immediately and replace it with the web font when it is loaded.



@font-face {
  font-family: 'Open Sans';
  font-display: swap;
  src: url('path/to/font.woff2') format('woff2');
}

3.Inline critical CSS: You can also inline the critical CSS in the head of the HTML document to ensure that the text is styled properly while the web fonts are being loaded.

4.Use preloading: Use the preload attribute to preload the web fonts in the head section of the HTML document. This will download the fonts in advance so that they are ready when needed.



<link rel="preload" href="path/to/font.woff2" as="font" type="font/woff2" crossorigin>

By implementing one or more of these solutions, you can eliminate the warning and ensure that the text remains visible during web font load.




Post Answer