即使在将font-display: fallback
添加到CSS之后,也无法在Google Pagespeed Insights报告中解决在Webfont加载期间文本仍然可见的问题。
如何解决该问题?
@font-face {
font-family: Jura;
src: url(../fonts/Jura-Regular.eot);
src: url(../fonts/Jura-Regular.eot?#iefix) format('embedded-opentype'), url(../fonts/Jura-Regular.woff2) format('woff2'), url(../fonts/Jura-Regular.woff) format('woff'), url(../fonts/Jura-Regular.ttf) format('truetype'), url(../fonts/Jura-Regular.svg#svgFontName) format('svg');
font-weight: 400;
font-display: fallback;
}
答案 0 :(得分:1)
我通过在index.html中的标记之间直接添加 @fontface 规则解决了此问题。 您也可以尝试在 @fontface 规则的顶部设置字体显示。
font-display: fallback;
font-family: 'Montserrat';
src: local('Montserrat'), url('https://fonts.googleapis.com /css?family=Montserrat:300,700') format('woff2');
font-style: normal;
font-weight: 700;
答案 1 :(得分:1)
我通过添加font-display:swap;
摆脱了它@font-face{
font-family:FontAwesome;
font-display: swap;
src:url(fonts/fontawesome-webfont.eot?v=4.5.0);
}
答案 2 :(得分:1)
可以通过在网站的head标签之间添加一个真棒的在线JS库来解决此问题。
https://fontawesome.com/how-to-use/with-the-api/setup/configuration#configuration
<html>
<head>
<script>
FontAwesomeConfig = {searchPseudoElements: true}
</script>
<script src="https://use.fontawesome.com/releases/v5.12.0/js/all.js"></script>
</head>
<body></body>
</html>