I am using lazy loading in my application. But my featured module is taking time to load once I visit that route. So to reduce that load time, I am using Angular Preloading Strategy. But due to that initial load time of app is increased.
Ideally, the features module should load in the background and should not increase the initial load time.
For preloading, I add this code to my routing module.
RouterModule.forRoot(routes, {preloadingStrategy: PreloadAllModules})
What could be the issue?
Yes. This is how pre-loading strategy works in Angular. Whenever any module is pre-loaded, it loads in background after loading all eagerly loaded and required lazily loaded modules. After that pre-loading of modules starts. As all pre-loaded modules are first compiled and loaded in case of normal build and dev build (non aot build), which increases load time of current module.
But in aot build this issue will not occur as most time is utilised in compiling the module which will be skipped in aot build.