DEV Community

Discussion on: Angular 9: Lazy Loading Components

Collapse
 
zombierobo profile image
Hasmukh Suthar

For people wondering what’s the use case of lazy loaded components, a good example is a pdf file download button. Rather than preloading the client side pdf maker library, we can embed the pdf maker library in a lazy loaded component which gets instantiated on click of download button. This reduces the size of chunk file that renders the page and delays fetching of the library chunk file until it is actually used.

Collapse
 
vitale232 profile image
Andrew Vitale

That's def a good use case for the apps we're building at work!

I came across this article that uses some newer web pack features and a service to achieve the same effect. It works great in an app with a more traditional "feature module" architecture. Maybe it's useful for you

medium.com/javascript-in-plain-eng...