Google PageSpeed Insights优先考虑可见内容 [英] Google PageSpeed Insights Prioritize visible content

查看:163
本文介绍了Google PageSpeed Insights优先考虑可见内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是在我的一个随机域名上进行一些测试,当我运行域名时 Google PageSpeed Insights 加载下面的JavaScript:

I am just doing some testing on one of my random domains and when I run the domain through Google PageSpeed Insights with the following JavaScript being loaded:

$("[data-min-height]").each(function() {
     var dataHeight = $(this).data("min-height");
     var dataPercent = dataHeight / 100;
     $(this).css("min-height", function() {
          return $(window).height() * dataPercent;
     });
});

我收到错误优先考虑可见内容。如果我拿走JavaScript,我不会再犯这个错误。我正在使用 matthiasmullie / minify 将我所有的JavaScript压缩在一起。目前我有 jQuery PaulSpr / jQuery-Flex-Vertical-Center liabru / jquery的匹配高度。一切都被编译成一个名为path.js的文件。我在关闭body元素之前加载了该文件,并使用了延迟。

I get the error Prioritize visible content. If I take away the JavaScript, I no longer get the error. I am using matthiasmullie/minify to compress all my JavaScript together. Currently I have jQuery, PaulSpr/jQuery-Flex-Vertical-Center, and liabru/jquery-match-height. Everything is compiled into one file called path.js. I load that file right before the closing body element and I use defer.

因此,如果任何人有任何想法说明为什么上面的JavaScript会导致PageSpeed出现此错误,将不胜感激。谢谢。

So if anyone has any ideas as to why the above JavaScript would cause this error on PageSpeed, it would be much appreciated. Thank you.

推荐答案

直接嵌入 path.js 的所有内容在您的HTML文档中。

Embed all the contents of path.js directly in your HTML document.

请阅读此处,了解优先显示内容

您的脚本可能用于呈现内容

you scripts might be used to render contents

这篇关于Google PageSpeed Insights优先考虑可见内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆