Reputation: 37
If I have an Angular or React Single Page application and some of the routes are lazy loaded, my understanding is that if a user opens the web app, some of the JS bundles won't immediately be sent to their browser. But if they navigate to some of the lazy-loaded routes, then the additional JS bundles will be sent to the browser.
Let's say I'm hosting the app on Firebase hosting, or some other CDN. How can the hosting server possibly implement the logic to know which JS bundles to send to the user? Am I misunderstanding something? I haven't seen much discussion online about this topic, but it doesn't make much sense to me.
Upvotes: -1
Views: 119
Reputation: 259
Hosting provider does not know; its not their job.
With code-splitting and dynamic import techniques, you can lazyload parts.
https://reactjs.org/docs/code-splitting.html#reactlazy
https://reactrouter.com/docs/en/v6/examples/lazy-loading
Upvotes: 1