Reputation: 1531
I have a number of web components consumed in a separate application. They all depend on React. React is not in the parent App, but all of the components will depend on React. Is it expensive to call and load React in each component, even over CDN? Or is there a better way to specify a common dependency shared by multiple web components?
Upvotes: 1
Views: 391
Reputation: 31199
Your browser will keep React in cache so even if you call it several times it will be downloaded once. You can see it in Chrome Dev Tools (HTTP code 304 Not Modified
). So it shouldn't impact overall performances.
If you use the Web Component technology you could leverage HTML Imports to load dependancies.
You could also use a module loader like RequireJs.
Upvotes: 1