Angular 9 preload only specific modules and preload other modules when required and not all at a time


    { preloadingStrategy: PreloadAllModules })

Angular’s official documentation provides this preloading strategy to preload all modules. However, I don’t want all of the several modules load up. I want sub-directories to preload after opening parent directory. Also, preload other possible modules which can be called from current active route. I don’t want all modules to preload at start. How do I do that?


You can introduce a data property with all routes to decide which modules to preload and which to not and implement PreloadAllModule and change implementation depending on this data flag.

Refer to :-

You can have custom preloading via having some custom code in Appcomponent, not via Preload strategy. For doing so refer to :-

Answered By – Aakash Garg

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published