How to compress Angular 11 application prod files
Asked Answered
D

2

5

I am working on an application I have made deployment of my application now the issue I am facing is some of my prod files taking too much time load here is the screenshot from my network tab. I have also tried --aot and optimizer command while making prod build How to overcome this?

enter image description here

Dodecahedron answered 5/1, 2022 at 14:43 Comment(0)
L
5

First approach is to have your production server serve gzipped files. This will considerably reduce load time. How you do this depends on your server, not on Angular.

The second (complementary) approach is to reduce your Angular bundle size. There are a million ways of doing that, not least by implementing lazy loading wherever possible

Laughter answered 5/1, 2022 at 14:55 Comment(0)
P
3

I would suggest using npm package gzipper

  1. Run npm install -g gzipper to install gzipper globally
  2. Run ng build --prod or your build script in angular project
  3. Run gzipper compress ./dist to compress the files in dist folder

Note: Enable gzip compression on server end

Patagium answered 5/1, 2022 at 15:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.