Explain Lazy Loading in Angular?

By default, NgModules are eagerly loaded, which means that as soon as the app loads, so do all the NgModules , whether they are immediately necessary. For large apps with lots of routes, consider lazy loading dash; a design pattern that loads NgModules as needed. Lazy loading helps keep initial bundle size smaller, which in turn helps decrease load time.

Angular Lazy Loading Steps:

There are 2 steps to create a lazy loading feature module

create feature module

configure loadChildren in appRouting

Feature module is a module specific to certain functionality

To load a feature module lazily (only on demand) we need to load its children using the loadChildren property in route configuration

Syntax:

ng g module users --route user --module app.module