font-face - 如何修复 PageSpeed 中的“确保文本在 webfont 加载 bootstrap-icons.woff 期间保持可见”错误
问题描述
确保在 webfont 加载期间文本仍然可见,即使在添加font-display:swap到 CSS之后,谷歌 pagespeed 洞察报告中也没有得到解决。
@font-face {
font-display: swap;
font-family: 'bootstrap-icons';
src: url('../fonts/bootstrap-icons.woff') format('woff'),
url('../fonts/bootstrap-icons.woff2') format('woff2');
}
解决方案
preload
并font-display: swap;
一起使用然后这个问题就解决了
<link href="../css/bootstrap-icons.css" rel="stylesheet preload" as="style" />
@font-face {
font-display: swap;
font-family: 'bootstrap-icons';
src: url('../fonts/bootstrap-icons.woff') format('woff'),
url('../fonts/bootstrap-icons.woff2') format('woff2');
}
推荐阅读
- c++ - 为什么while循环在c ++中跳过嵌套循环的第一次迭代的几行?
- laravel - Laravel 作为多个远程客户数据库的后端
- azure - AKS Azure 中的微服务与负载均衡器集成
- python - 如何在views.py类中添加页数而不会出错[Django]
- google-sheets - 条件格式 Google 表格的规则对我来说很复杂
- python - 我正在尝试使用 treminal 在 mac os 上安装 pycups,但我收到“pycups (setup.py) ... 错误”
- java - 使用 OpenJPA 时在 VM 参数中添加 java 代理时出错
- jdbc - Nifi gmail 开源 jdbc 驱动
- python - 如何修复python中的条形图(自定义条形图)?
- excel - 如何在 SharePoint 上“签入”上传的文档?