简体   繁体   English

Angular2应用-删除渲染阻止JavaScript

[英]Angular2 app - Remove Render-Blocking JavaScript

I have an angular2 firebase app. 我有一个angular2 firebase应用程序。

I've noticed that when live it task 4 seconds to get 12 JavaScript libraries that I store locally in my prod build and then it shows the app. 我注意到,实时直播需要4秒钟的时间来获取12个JavaScript库,这些库我存储在本地产品中,然后显示了该应用程序。

I need to get this 4 second delay down to 2 seconds. 我需要将这4秒的延迟降低到2秒。

When I watch the sources in the console in chrome it just pauses for 4 seconds then loads. 当我在Chrome控制台中查看源代码时,它会暂停4秒钟,然后加载。 It seems to be render blocking JavaScript the correct term? 似乎是渲染阻止JavaScript的正确术语?

Things I've tried: 我尝试过的事情:

  • HTML5 async and defer on the 12 JavaScript libraries. HTML5 异步处理并在12个JavaScript库上进行延迟
  • I tried combining the libraries into the same file but that gave me loads of errors. 我尝试将库合并到同一文件中,但这给了我很多错误。
  • My CSS is fine and all minified. 我的CSS很好,并且全部缩小。
  • All the js 12 files are minified. 所有的js 12文件都已缩小。
  • The 12 JavaScript libraries are all stored locally and not requested from other servers. 这12个JavaScript库全部存储在本地,并且不需要其他服务器的请求。
  • I have images on my website and they are all optimized and compressed and placed on a CDN. 我的网站上有图像,它们都经过了优化和压缩,并放在CDN上。
    • I use cloudflare and all the performance toggles are on. 我使用cloudflare,并且所有性能切换均处于启用状态。
    • I host with Firebase. 我托管Firebase。
    • The JavaScript files are below the and not in the header. JavaScript文件位于下方,而不位于标头中。

My PageSpeed Insights scoress from google: (Resource: https://developers.google.com/speed/pagespeed/insights/ ) 我对Google的PageSpeed Insights得分:(资源: https : //developers.google.com/speed/pagespeed/insights/

  • 61/100 for mobile. 手机为61/100。
  • 83/100 for desktop. 台式机为83/100。

I can't use webpack. 我不能使用webpack。

I just want an easy method for showing the user interface and then load the libraries. 我只想要一种简单的方法来显示用户界面,然后加载库。

Let me know if you have any further questions. 如果您还有其他问题,请告诉我。

Angular 2 generates your user interface, so what you are asking seems impossible at first. Angular 2会生成您的用户界面,因此您最初提出的要求似乎是不可能的。 But you are in luck: the angular 2 team is working on something to help you out. 但是,您很幸运:Angular 2团队正在努力为您提供帮助。 It is actually already ready to use, but i don't think you can use it in combination with Firebase hosting. 它实际上已经可以使用了,但是我认为您不能将它与Firebase托管结合使用。 Take a look at https://universal.angular.io/ . 看看https://universal.angular.io/ It allows you to render the initial view on the server side. 它允许您在服务器端呈现初始视图。

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

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