且构网

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

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

更新时间:2023-11-22 17:57:40

代码拆分"怎么样.

来自 Webpack 站点:

From the Webpack site:

对于大型 Web 应用程序,将所有代码放入单个文件中效率不高,特别是如果某些代码块仅在某些情况下才需要.Webpack 具有将代码库拆分为按需加载的块"的功能. 其他一些打包程序将它们称为层"、汇总"或片段".此功能称为代码拆分".

"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.