The traditional advice for web developers is to bundle the JavaScript files used by their webpages into one or (at most) a few "packages." Multiple tools have been developed to do this, such as Browserify and Webpack. They tend to work like this: for a given HTML page, you write a single JavaScript source file that provides all the JS logic needed for that page.
Full article