Skip to content

Lazy Loading Modules and Components

Lazy loading improves initial load performance.

Router example:

import { Routes } from '@angular/router';
export const routes: Routes = [
{
path: 'dashboard',
loadComponent: () =>
import('./dashboard/dashboard.component').then(m => m.DashboardComponent)
}
];
``
Explanation:
- `loadComponent` dynamically imports component
- Reduces initial bundle size