Lazy Loading in Angular 6|7|8 – Angular Provides many different ways to work with the application routing. Lazy Loading is also one of them. In this article, we will talk about what is lazy loading and how you can use it in your angular application with an example.
Lazy loading provides features like loading of the required component and not loading the entire application at once. We are going to learn all of this and also how to implement this. So without wasting more time, let’s dive in.
Lazy Loading in Angular
What is Lazy Loading in Angular?
NgModules are eagerly loaded, which means that as soon as the app loads, so do all the NgModules, whether or not they are immediately necessary. For large apps with lots of routes, consider lazy loading—a design pattern that loads NgModules as needed.
With Lazy loading, you can only load the required component at the starting of the angular app and call further components when their specific routes are called. This can add some initial performance during the initial load, especially if you have many components with complex routing.
Advantage of Lazy Loading in Angular?
- High performance in bootstrap time on initial load.
- Modules are grouped according to their functionality.
- Smaller code bundles to download on initial load.
- Activate/download a code module by navigating to a route.
So, that’s all about Lazy Loading in Angular. Thanks for reading!