如何在CSS中设置rel = preload?

问题描述 投票:0回答:1

我导入这样的字体:

@font-face{
    font-family:fname;
    src:url(../fonts/fname.woff) format('woff'),
    url(../fonts/fname.ttf) format('truetype');
    font-weight:400;
}

[另外,当我使用SEO工具(例如Google页面速​​度分析)分析我的网站时,他们建议对这些字体使用rel="preload"。因为我不使用HTML将字体导入页面,所以我知道如何使用CSS使用HTML属性吗?

html css rel
1个回答
0
投票

您可以尝试以下方法:

<link rel="preload" as="font" href="../fonts/fname.woff" type="font/woff" crossorigin="anonymous">

也可以检查this post

© www.soinside.com 2019 - 2024. All rights reserved.