且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何提高Angular2应用程序的加载性能?

更新时间:2023-11-22 18:06:16

代码拆分怎么样。

来自Webpack网站:

From the Webpack site:

对于大型网络应用程序,将所有代码放入单个文件中效率不高,特别是在某些情况下只需要某些代码块的情况下Webpack有一个功能,可以将你的代码库分成按需加载的块。其他一些捆绑包称它们为层,汇总或fra gments。此功能称为代码拆分。

"For big web apps it’s not efficient to put all code into a single file, especially if some blocks of code are only required under some circumstances. Webpack has a feature to split your codebase into "chunks" which are loaded on demand. Some other bundlers call them "layers", "rollups", or "fragments". This feature is called "code splitting".

此处链接:

https://webpack.github.io/docs/code-splitting.html

请注意,Angular CLI使用Webpack。

Note that the Angular CLI uses Webpack.

另外,如果您的应用程序使用数据调用进行引导,请确保您没有阻止等待这些调用返回的组件的呈现。承诺,异步等。

Also, make sure that if your app bootstraps with data calls, that you are not holding up the rendering of your components waiting on those calls to return. Promises, async, etc.