有人能告訴我爲什麼以下工作渲染延遲腳本突然無法通過Google Pagespeed Insight Test?推遲上面的CSS渲染突然無法通過Google Pagespeed Insight Test
<script>
function loadCSS(href){
var ss = window.document.createElement('link'),
ref = window.document.getElementsByTagName('head')[0];
ss.rel = 'stylesheet';
ss.href = href;
// temporarily, set media to something non-matching to ensure it'll
// fetch without blocking render
ss.media = 'only x';
ref.parentNode.insertBefore(ss, ref);
setTimeout(function(){
// set media back to `all` so that the stylesheet applies once it loads
ss.media = 'all';
},0);
}
loadCSS('link.css');
</script>
<noscript>
<!-- Let's not assume anything -->
<link rel="preload" href="link.css" as="style" onload="this.rel='stylesheet'">
</noscript>
的頁面是http://www.landshoppe.com/
我使用
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js" data-pagespeed-orig-type="text/javascript" async></script>
在頁腳