Splitting your Angular app into several smaller bundles can make your site faster by reducing download and execution times. Instead of loading all code upfront it's fetched lazily when needed.
Most guides to lazy loading Angular modules use Angular's RouterModule
and the loadChildren
property to load code when the user first navigates to a certain page. But that means you can't lazy load code if whether the code is needed doesn't depend on a route change.
This article will explain how to lazy load Angular feature modules independently of the router.