downloading one file is faster than downloading three

How to combine external javascript

Javascript files are very often found in several external files. There is not always a need to have these files be separate as most javascript can be combined into one file and not affect the ways it functions.

Collecting all javascript files into one will really reduce the amount of time it takes to load your web pages because you are reducing the amount of things the web browser has to request before displaying your page.

Tip: See how many scripts your page is loading with our resource check tool.

Wordpress users pay attention

If you use Wordpress, I can almost guarantee that your blog is loading several (likely 6 or more) external javascript files. It does not have to be this way.

How to combine your javascript

You can often just copy and paste the contents of each javascript file together to make one main JS file.

For example, you may have a javascript file called "this.js" and another called "that.js" being called by your HTML. In this situation your could open your "this.js", copy and paste the contents of the file into "that.js".

Once you have done that, you would remove the call for "this.js" from your HTML. You now have just one JS file instead of two that a web browser must load before displaying your webpage. Your webpage will now load faster.

Other javascript pagespeed tactics to consider

You can also choose to inline small javascript or defer your javascript for even more savings.

by Patrick Sexton