Will a dependency slow every page of a web app

I realized I have a lapse in my understanding of bundlers. Does bundling combine all the code together into one file or would it happen on a page by page basis. Ergo, would a big package/dependency like three.js slow down every page (even if only just a little) or will it only slow down the page in which it is imported and used. P.S. Now that I write it down I feel like it has to be page by page but still thought it’s worth asking to be sure
2 Replies
FleetAdmiralJakob πŸ—• πŸ—— πŸ—™
To solve this problem there is lazy loading where each dependency only gets loaded if it's needed. Frameworks like Next.js automatically lazy load dependencies whereas with React you have to do it manually. For more information look at this for example: https://react.dev/reference/react/lazy
lazy – React
The library for web and native user interfaces
dylancam812
dylancam812OPβ€’10mo ago
Thank you!
Want results from more Discord servers?
Add your server