简体   繁体   English

删除阻止渲染的JavaScript

[英]Remove render-blocking JavaScript

i am developing a web in angularjs. 我正在用angularjs开发网站。 there are approx 42 javascript files which i have to load. 我必须加载大约42个javascript文件。 Google PageSpeed Insight ask to remove Remove render-blocking JavaScript. Google PageSpeed Insight要求删除删除阻止渲染的JavaScript。

    <script async src="path to file"></script> 

it load files asyn but jquery.js file loading after files which need jquery file.i am stuck because site taking a lot of time to load.Please help.Thanks in advance 它加载文件asyn但在需要jquery file的文件之后加载jquery.js文件。我被卡住了,因为网站加载时间很长。请帮助。

关于实现该目标的不同方法,可以有很长的答案(使用模块和http://requirejs.org/https://github.com/systemjs/systemjs ),但是TL; DR- 尝试将jQuery脚本调用放入您的网页的head标签 ,而其他脚本则位于html页面的底部。

Found this discussion which helps to address the pagespeed insights "problem" and improves (in my opinion) the UX. 发现了这个讨论该讨论有助于解决pagespeed见解的“问题”并改善了UX(在我看来)。 Here is Sander's suggestion: 这是桑德的建议:

<div ng-if="false">
  <h1>Loading the application, please hold on</h1>
  <div class='aCssSpinner'</div>
</div>

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

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