javascript - Angular7缓慢的页面加载
问题描述
我有一个传递给我的 Angular7 应用程序。第一次内容丰富的绘画和互动时间约为 6 秒!在https://www.google-analytics.com/collect和https://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 之前,我想确保没有其他可以改进的地方。谢谢!
解决方案
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
推荐阅读
- android - Android Firebase 不适用于颤振网络
- python - 为什么目标编码器将某些值编码为 NaN?
- mongodb - 如何使用 mongo 驱动程序在 Golang 中实现 MongoDB 自动完成?
- c# - 在实体框架中执行存储过程 - 没有定义键。(代码优先)
- javascript - 引用外部脚本和资源而不是将它们“本地”下载到您的服务器是否安全?
- java - OkHttp 这个浏览器不支持框架
- vb.net - 如何在 vb 中获得唯一的 chrome ID?
- python - [AZURE]OSError:libgomp.so.1:无法打开共享对象文件:没有这样的文件或目录
- python - 获取积分以创建 KDE 图
- sql - SQL 按 10 个最大项分组