简体   繁体   English

Google PageSpeed冲突建议

[英]Google PageSpeed Conflicting Suggestions

When it comes to loading CSS, Google PageSpeed has conflicting recommendations. 在加载CSS时,Google PageSpeed的建议存在冲突。

On the one hand, it tells us to load all CSS in the head: https://developers.google.com/speed/pagespeed/service/MoveCSSToHead?csw=1 一方面,它告诉我们将所有CSS加载到头部: https//developers.google.com/speed/pagespeed/service/MoveCSSToHead?csw = 1

On the other hand it tells us to only put the priority CSS in the head and insert the rest after the page has fully loaded: https://developers.google.com/speed/docs/insights/OptimizeCSSDelivery 另一方面,它告诉我们仅将优先级CSS放在顶部,然后在页面完全加载后插入其余CSS: https//developers.google.com/speed/docs/insights/OptimizeCSSDelivery

So which rule do I follow? 那么我该遵循哪一条规则? Also, if anyone can point me to an example of how to load the CSS using Javascript after "onLoad", I will be very grateful. 另外,如果有人可以指出“ onLoad”之后如何使用Javascript加载CSS的示例,我将不胜感激。

99% of the time all CSS should be in the head in the form of a external link. 99%的时间,所有CSS都应以外部链接的形式置于头部。 And all js should be just before the closing body tag. 并且所有js都应该在body标记之前。 If its telling you to put the css in the body it is wrong. 如果它告诉您将CSS放入体内,那是错误的。 page speed is not just actual speed. 页面速度不仅仅是实际速度。 it is also perseived speed. 它也被认为是速度。 css in the head will make the page appear to load faster. 头部的css将使页面加载速度更快。 Here are all the ways to load CSS with js that I know of. 这是我所知道的用js加载CSS的所有方法。 http://www.websitecodetutorials.com/code/javascript/add-css-with-javascript.php . http://www.websitecodetutorials.com/code/javascript/add-css-with-javascript.php

The idea here is that you inline the CSS rules that the page actually needs to render initially into the head tag, and defer loading of the rest of the CSS until after the page load. 这里的想法是,将页面实际需要呈现的CSS规则内联到head标签中,并将其余CSS的加载推迟到页面加载之后。

For an example, see http://www.iispeed.com/mod_pagespeed_example/prioritize_critical_css.html?PageSpeed=on&PageSpeedFilters=rewrite_css,flatten_css_imports,inline_import_to_link,prioritize_critical_css 有关示例,请参见http://www.iispeed.com/mod_pagespeed_example/prioritize_critical_css.html?PageSpeed=on&PageSpeedFilters=rewrite_css、flatten_css_imports、inline_import_to_link、prioritize_critical_css

Hi recently we have created an opensource nodejs framework called "elegant framework" that help you building fast web application and we succeeded to get 100% google page speed in both desktop and mobile in all pages : you can check it at: 嗨,最近,我们创建了一个名为“优雅框架”的开源nodejs框架,可帮助您构建快速的Web应用程序,并且我们成功实现了所有页面在台式机和移动设备上的Google页面浏览速度均为100%:您可以在以下位置进行检查:

https://developers.google.com/speed/pagespeed/insights/?url=getelegant.com https://developers.google.com/speed/pagespeed/insights/?url=getelegant.com

there is a lot of things you can learn from it by viewing the page source also if anything you cannot understand please comment so i can help you with 通过查看页面源代码,您可以从中学到很多东西,如果您无法理解,请发表评论,以便我为您提供帮助

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

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