'How should I load/bundle js libraries needed in 2 indipendent js ES modules?
Ok, I'm relatively new to js modules, I tried to find an answer to this question but till now I didn't. I was used to pack all the dependencies in one big js file, shared between several pages. I then loaded another page-specific js file after the shared 'bundle'.
all-pages: shared.js // browser-cached
page-1: page-1-specific.js, loaded after shared.js, uses libraries in shared.js
page-2: page-2-specific.js, loaded after shared.js, uses libraries in shared.js
etc..
Now with modules, if I try to pack several libraries this way, they won't be available to other js files, since anything inside a module can't be 'global' to the page. Ok.
So I should import dependency libraries on any page-specific js. But this way I would have libraries loaded in every page instead of taking advantage of broeser caching.
So what exactly is the way of doing this with es modules nowadays?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
