Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angular 5 lazy loading vs dynamic loading

Tags:

Can somebody explain the difference between lazy loading modules and dynamic component loading in angular 5? I have some hard time to figure out when what to use. Can you provide a use case for each so I can better understand them? I am pretty new to angular 5... I know that lazy loading is about modules and dynamic components loading is about components.

like image 917
user2818430 Avatar asked Feb 13 '18 12:02

user2818430


1 Answers

With lazy loaded modules the browser will only load features when the user navigates to their routes for the first time. When you add components directly to your routes they will be loaded regardless if you are in any particular route, so in terms of performance and initial bundle size it is always good to have features lazy loaded.

Reference: https://alligator.io/angular/lazy-loading/

like image 129
crdevdeu Avatar answered Nov 15 '22 05:11

crdevdeu