首页 > 解决方案 > Angular7缓慢的页面加载

问题描述

我有一个传递给我的 Angular7 应用程序。第一次内容丰富​​的绘画和互动时间约为 6 秒!在https://www.google-analytics.com/collecthttps://fonts.gstatic.com/s/opensans API 调用上似乎停滞(待处理)大约 4 秒,我发现这与谷歌字体有关. 但这可能不是失速的原因。我尝试使用延迟加载模块来缩小捆绑包。目前我们在:styles.css 465B,runtime.js 1.1kB,polyfills.js 36kB,styles.js 10kB,vendor.js 583kB,main.js 142kB。捆绑包大小似乎不是问题,但浏览器(chrome)在用户看到主页之前仍会停止 6 秒。有人有什么建议吗?

我还查看了 SSR,但考虑到我们使用 dist 中的内容在 AWS S3 上提供服务,设置似乎非常复杂。我正在建造:

ng build --outputHashing=all --prod

请帮忙。在尝试 SSR 之前,我想确保没有其他可以改进的地方。谢谢!

标签: javascriptangularangular7angular7-router

解决方案


You can try to optimize your code a bit and use the AOT compilation mode in the time of building.

I found a good article, you can explore this and understand in what way exactly you can improve your code and reduce loading time. https://www.dotnettricks.com/learn/angular/tips-to-optimize-your-angular-application


推荐阅读