Skip to content Skip to sidebar Skip to footer

Including All Scripts In Separate File

Making a site and I have a number of scripts piling up. I was thinking to myself it might be better to have a separate file to 'include' all my scripts without the clutter in my ma

Solution 1:

browserify, webpack and requirejs are currently some popular bundling libraries.

Alternatively, you can simply concatenate all of your scripts into one file either manually using something like the cat command in your terminal, or automatically, by using npm or a task runner like grunt or gulp then just include that file in your html. The benefit of using something like npm, gulp or grunt is that you can automatically watch your files for any changes, and when changes occur, it will concatenate all your various javascript files together for you.

Solution 2:

You may want to look into using HTML5 Imports using web components (http://webcomponents.org/) and polymer (https://www.polymer-project.org/1.0/), html imports and polyfill are native in chrome and then use simply use provided scripts for browser compatibility in IE and FF.

Post a Comment for "Including All Scripts In Separate File"