简体   繁体   English

为什么我“消除了渲染阻止资源”后却得到较低的PageSpeed分数?

[英]Why do I get a lower PageSpeed score after I “eliminate render-blocking resources”?

I'm brand new to PageSpeed and trying to get a grasp on the various aspects it wants me to optimize. 我是PageSpeed的新手,并试图掌握要我优化的各个方面。 Is there a guideline I can follow, such as what code can be removed, deferred, etc.? 有没有我可以遵循的准则,例如可以删除,推迟执行的代码等? I am by no means a developer. 我绝不是开发人员。

My score fluctuates with each .js file I defer. 我的分数随我延迟的每个.js文件而变化。 Sometimes it gets better, sometimes it gets worse. 有时会变得更好,有时会变得更糟。 This doesn't make sense to me and is rather frustrating. 这对我来说毫无意义,令人沮丧。

I expect the PageSpeed score to improve, but instead it fluctuates and sometimes gets worse with each .js file I defer. 我希望PageSpeed得分会有所提高,但随着我推迟的每个.js文件的出现,它都会波动甚至变差。

While PageSpeed shows some interesting statics such as first contentful paint, time to interactive etc. It's hard to figure out what is going under the hood without looking at a timeline of the page loading process. 虽然PageSpeed会显示一些有趣的静态信息,例如内容丰富的绘画,进行交互的时间等。如果不查看页面加载过程的时间轴,就很难弄清楚到底是什么。 The screen shot below shows how your page loads in google chrome. 下面的屏幕快照显示了您的页面如何在Google chrome中加载。 You can view this yourself by following this guide: https://developers.google.com/web/tools/chrome-devtools/network/ 您可以按照以下指南自己进行查看: https : //developers.google.com/web/tools/chrome-devtools/network/

开发工具截图

One of the major holdbacks is your server response time, the server takes at least 2 seconds to handle the request for the website, which is quite high and leads me to believe that you maybe on a cost effective plan on hostmonster. 主要的阻碍因素之一是服务器的响应时间,服务器至少需要2秒钟来处理对网站的请求,这相当高,这使我相信您可能在hostmonster上制定了具有成本效益的计划。 In contrast StackOverflow.com responds in 300ms. 相反,StackOverflow.com的响应时间为300ms。 An easy way to benchmark your webhost is by running this test on a fresh wordpress installation. 基准测试虚拟主机的一种简单方法是在全新的wordpress安装上运行此测试。 It will tell you whether an inefficient wordpress setup on your part is causing the delay or whether the host is inherently slow at serving php. 它会告诉您您自己的效率低下的wordpress设置是否会导致延迟,或者主机在服务php方面天生缓慢。 I have a feeling that there is significant bloat in your php code causing this. 我有一种感觉,您的php代码中有很大的膨胀导致了这种情况。

Next you have a css file that takes 880ms and is 200kb compressed but 1.9Mb uncompressed (shown as 1 860 013 bytes in the coverage tab) This is extremely big and should not exceed 1Mb even on the largest of websites. 接下来,您有一个CSS文件,耗时880ms,压缩后为200kb,但未压缩1.9Mb(在Coverage标签中显示为1 860 013字节),这非常大,即使在最大的网站上也不应超过1Mb。 98.6% of your CSS file is unused. CSS文件的98.6%未使用。 It is not uncommon to have over 90% unused CSS when using a generic framework, but generic frameworks never have a css file that is close to 2MB. 使用通用框架时,有90%以上的未使用CSS并不罕见,但是通用框架永远不会有接近2MB的css文件。 A css bundle is below 500kb on most websites. 大多数网站上的css捆绑软件都低于500kb。 Not only does this add to the download time, it also adds to the time required for the browser to parse that file and render the page. 这不仅增加了下载时间,还增加了浏览器解析该文件并呈现页面所需的时间。

There's also the header image which is 423KB in size an takes 1.3s to download. 还有一个标题图像,大小为423KB,下载需要1.3秒。 Usually, an image of that resolution can be compressed to less than a 100kB. 通常,该分辨率的图像可以压缩到小于100kB。

The red line on the water fall indicates when the page is considered to be fully loaded. 瀑布上的红线表示何时认为页面已满。 The oversized header is adding a lot to it. 过大的标题给它增加了很多。 While the entire process of loading is pushed back by 2.2s due to the server response time. 由于服务器的响应时间,整个加载过程推迟了2.2s。 You'll see that the script loading times are marginal compared to the effect that these two have. 您会看到,与这两个脚本相比,脚本的加载时间微不足道。 This may by why you observed an indifference in loading times when you changed the tags to defer. 这可能就是为什么您在更改标签以推迟时观察到加载时间无关紧要的原因。

To summarize, look into why it takes 2+s for the server to respond, clean up your CSS. 总而言之,调查一下为什么服务器需要2秒钟以上的时间才能做出响应,因此请清理CSS。 Aim for half the size. 力争尺寸的一半。 Compress your header image. 压缩标题图片。 Aim for around 100kb. 目标大约100kb。 Once you fix these, you can look into deferring scripts to achieve the optimal loading time. 修复这些问题后,您可以研究延迟脚本以实现最佳加载时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM