How can I improve load performance of Angular2 apps?

前端 未结 6 1510
走了就别回头了
走了就别回头了 2020-12-04 06:47

Angular2 app is loading slow, how can I improve the performance on load?

I use Angular2, typescript with html5.

currently my app takes 4 seconds to load. I h

6条回答
  •  半阙折子戏
    2020-12-04 07:32

    How about "code splitting".

    From the Webpack site:

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

    Link here:

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

    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.

提交回复
热议问题