Eager Loading, Lazy Loading Strategies In Angular

Angular has provided 3 types of module loading strategies. Every module loading strategy has its own way of implementation. In this post, we will know about what is the basic definition and benefits of every loading strategy. 

Why we use loading strategy ? It is necessary to load the feature modules or components that are required to render an application. Based on our requirements, We need to know which loading strategies will suitable to our application.

1. Eager Loading 
2. Lazy Loading
3. Pre Loading

Eager Loading : It is the default loading strategy to load the components in angular application. It is useful in small size applications. 

In Eager Loading all the components will be loaded before the application starts. It makes subsequent request to the application will be very faster.

In Eager loading, all the components will import in app.module.ts.




Lazy Loading : It loads only the required feature modules to render the page in application. In Lazy loading, feature module will loaded on demand and hence application start will be much faster.

It helps render an application much faster than eager loading. It will use for large applications. It is useful when application size is growing.

In Lazy loading strategy, no need to import the feature modules in app.module.ts.


In Lazy loading, we will use the 'loadChildren' property in route configuration. 

Comments

Popular posts from this blog

Create Custom Form Control for ng-select in Angular

Configure the API gateway in Microservices Architecture with example in .NET Core

Domain Driven Design (DDD) in .NET Core

Content Negotiation in Web API with example

Send API POST Request in MS SQL Server

Restrict Special Characters in Windows Application using c#

How to Create Custom DialogBox using JQuery

HTTP and grPC Communication protocols used in Microservices

CORS (Cross-Origin Resource Sharing) in .NET