What is lazy loading?

Lazy loading is one of the most useful concepts of Angular Routing. It helps us to download the web pages in chunks instead of downloading everything in a big bundle. It is used for lazy loading by asynchronously loading the feature module for routing whenever required using the property loadChildren. Let's load both Customer and Order feature modules lazily as below,

const routes: Routes = [
path: 'customers',
loadChildren: () =>
import('./customers/customers.module').then((module) => module.CustomersModule),
path: 'orders',
loadChildren: () => import('./orders/orders.module').then((module) => module.OrdersModule),
path: '',
redirectTo: '',
pathMatch: 'full',

September 16, 2022