【发布时间】:2020-11-12 21:37:42
【问题描述】:
Google 建议“考虑使用<link rel=preload> 来优先获取当前在页面加载后期请求的资源。”但是没有例子说明我们在使用@font-face 方法时应该如何使用它。
我应该改用 HTML 字体加载方法吗?
我现在使用什么来加载我的自定义字体:
@font-face {
font-family: 'Custom';
src: url("../fonts/Custom-Bold.eot");
src: local("☺"), url("../fonts/Custom-Bold.woff") format("woff"), url("../fonts/Custom-Bold.ttf") format("truetype"), url("../fonts/Custom-Bold.svg") format("svg");
font-weight: 600;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: 'Custom';
src: url("../fonts/Custom-Heavy.eot");
src: local("☺"), url("../fonts/Custom-Heavy.woff") format("woff"), url("../fonts/Custom-Heavy.ttf") format("truetype"), url("../fonts/Custom-Heavy.svg") format("svg");
font-weight: 800;
font-style: normal;
font-display: swap;
}
【问题讨论】:
-
这能回答你的问题吗? Preloading Google Fonts