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.