【发布时间】:2021-04-02 03:55:18
【问题描述】:
我正在按如下方式预加载谷歌字体
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="preload" href="https://fonts.googleapis.com/css2?family=Fira+Code&family=Montserrat:wght@400;500;800&display=swap" as="style">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Fira+Code&family=Montserrat:wght@400;500;800&display=swap">
但是,灯塔仍然给我 151 毫秒的累积布局移位,我可以看到字体闪烁。 为什么预加载不起作用?
还有。如果我从 display=swap 更改为 optional,lighthouse 会说“带有 font-display 的字体:未预加载可选字体”。这一定意味着它实际上没有预加载
【问题讨论】:
标签: javascript html css lighthouse