How can I improve load performance of Angular2 apps?

前端 未结 6 1505
走了就别回头了
走了就别回头了 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:15

    Build your angular app using following command to get maximum optimization benefits.

    ng build --prod --aot --optimization --build-optimizer --vendor-chunk --common-chunk --extract-licenses --extract-css --source-map=false
    

    Basically you will build in aot mode and use treeshaking with some optimization.

    • optimization: Enables optimization of the build output.

    • vendor-chunk: Use a separate bundle containing only vendor libraries.

    • common-chunk: Use a separate bundle containing code used across multiple bundles.
    • extract-css: Extract css from global styles onto css files instead of js ones.
    • build-optimizer: Enables @angular-devkit/build-optimizer optimizations when using the 'aot' option.
    • source-map=false: remove source map will also reduce bundle size

提交回复
热议问题