[英]Options to solve JavaScript and CSS in above-the-fold content
I validate a site using Google's Page Speed and I get the following error: 我使用Google的Page Speed验证了网站,并收到以下错误消息:
Eliminate render-blocking JavaScript and CSS in above-the-fold content
Your page has 1 blocking script resources and 1 blocking CSS resources. This causes a delay in rendering your page.
JAVASCRIPT JAVASCRIPT
I have two javascript files on bottom of my page: 我在页面底部有两个JavaScript文件:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="/scripts/main?v=5jyyqQNx45M0Mbw-ZD6J9SVac8LfWyZZLh_wq6HtfQI1" type="text/javascript" async></script>
I am getting JQuery from Google CDN and Main.js from local server. 我从Google CDN获得JQuery,从本地服务器获得Main.js。
I applied async to Main.js but this does not solve it ... 我对Main.js应用了异步,但这并不能解决问题...
... The only thing that solves this is adding async also to JQuery from Google's CDN. ...解决此问题的唯一方法就是从Google的CDN向JQuery添加异步。
But then the code in Main.js using JQuery stops working ... No idea why. 但是然后Main.js中使用JQuery的代码停止工作了……不知道为什么。
CSS CSS
I am not sure what to do to solve it. 我不确定该怎么做。 Any suggestion? 有什么建议吗?
Could someone, please, help me out? 有人可以帮帮我吗?
Thank You, Miguel 谢谢米格尔
But then the code in Main.js using JQuery stops working ... No idea why. 但是然后Main.js中使用JQuery的代码停止工作了……不知道为什么。
That code breaks, because jQuery is loaded after Main.js is executed and as Main.js depends on it .. well, it's going to fail. 该代码中断了,因为jQuery是在Main.js执行后加载的,并且因为Main.js依赖于它..很好,它将失败。
You won't come around loading your CSS and JS, therefore there isn't really anything you could do - Except using pure HTML. 您将不会加载CSS和JS,因此实际上您无能为力-除了使用纯HTML外。
The linked google help page says: 链接的Google帮助页面显示 :
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.