问题描述
Google Pagespeed测试与样式表一起使用时无法识别预加载.我尝试过
Google Pagespeed test doesn't recognize preload when it is used together with stylesheet. I tried
<link rel="preload stylesheet" href="http://www.example.com/style.css" />
,它仍然显示考虑用于优先获取当前在页面加载中稍后请求的资源".如果我从rel属性中删除样式表,它将识别出预加载.
and it still shows "Consider using to prioritize fetching resources that are currently requested later in page load.". If I remove stylesheet from rel attribute, it recognizes the preload.
我当时想尝试一下:
<link rel="preload" rel="stylesheet" href="http://www.example.com/style.css" />
但是我不确定您是否可以为同一链接标记具有2个相同的属性.这行得通吗?
but I am not sure if you can have 2 the same attributes for the same link tag. Would this work?
推荐答案
要异步加载CSS样式,
NOTE: As @JohnyFree tested the second one (one with a line through) in the Google page speed, it won't be recognized as valid preload
style, whilst the format is valid according to W3.org.
这篇关于如何同时使用rel ="preload"和rel ="preload".和rel ="stylesheet"对于相同的标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!