angularperformanceoptimizationpage-load-time

Angular application first page loading time issue and its up to 9 seconds


I am trying to fully optimize Angular 7 application and my bundles sizes are:

 main.js.map (main) 2.05 MB
 polyfills.js.map (polyfills) 237 kB
 runtime.js.map (runtime) 14.2 kB
 scripts.js.map (scripts) 1.02 MB
 styles.js.map (styles) 381 kB 

but when i run this command:

ng build --prod --aot && gzipper --verbose ./dist && ng run my-app:server:production

it make a server.js file with 27mb size and when i upload this to my dev server , Application load time is 9.2 seconds

I don't know why server.js file size is so huge. Can anyone help me to resolve this issue, than i can go ahead with 1 to 2 seconds with my Angular App load time.


Solution

  • Seems like you are not using lazy load module feature provided by Angular. Pleas use this. Lazy loading helps keep initial bundle sizes smaller, which in turn helps decrease load times.

    More information can be found at Lazy load feature modules