Skip to main content

What is lazy loading of routes?

Lazy loading of routes is a way to load parts of the application only when they are actually needed, instead of loading everything at startup.


Why it's needed:

  • Reduces the initial weight of the application
  • Speeds up the first load
  • Makes large projects more flexible and scalable

How it works:

  1. You have an AdminModule that not every user needs right away.
  2. Instead of a direct import, you point to it from the routing config:
ts
{ path: 'admin', loadChildren: () => import('./admin/admin.module').then(m => m.AdminModule) }
  1. When the user navigates to /admin, Angular lazily loads the module and its components.

Summary: Lazy loading is deferred, on-demand loading that helps avoid pulling in the whole project at startup.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.