我正在按以下方式预加载谷歌字体
<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">
然而,Lighthouse 仍然显示了151ms的累积布局位移,并且我可以看到字体在闪烁。为什么预加载不起作用?
另外,如果我从 display=swap 更改为 optional, Lighthouse 就会显示“具有 font-display: optional 的字体未预加载”。这必须意味着它实际上没有被预加载。