Let's say I have component C defined in script S1. Now, on a different page of my web-app, I want to display an instance of C in script S2 without having to redefine C in S2. How can I accomplish this?
1) Assign C to some global window property, load the script S1 first and access it with window.C from script S2. This works in simple cases but is a bit messy.
2) Use a module bundler like webpack. It comes with many configuration options but basically solve your problem.