Speed Up Your Site By Moving JavaScript Down

One day, I was looking for a way to speed up the page load times of my blog. I changed many things, but one of the most useful in WicketPixie’s case was moving links to JavaScript files down to the bottom of the page.

Let me first explain why moving links to scripts down to the bottom of a page speeds up the loading of that page. The HTTP/1.1 specification says that clients should limit downloading to two parallel downloads at a time per hostname. However, most browsers will stop parallel downloading if they reach a JavaScript link. So instead of loading the JavaScript file and the rest of your page, it stops to finish loading the JavaScript file first.

If the links to external JavaScript files are at the bottom of your page, HTML, CSS, images, and the page’s content will be loaded first, then each JavaScript file will be loaded one at a time. This will greatly improve page load times, because the user will first be able to see the page’s content, while the functionality the JavaScript adds is loading in the background.

One flaw is AdSense’s JavaScript that loads the ads. You must place these throughout the page, so the page loading will be blocked by those. I will see if I can post a solution to that later, in the meantime, search Google for some answers.

So, why should you go through the trouble to speed up your page loads? Well the answer is obvious: the more time a visitor waits for your page to load, the more impatient they become. So don’t lose a visitor because your JavaScript files kept your page from loading quickly.

Leave a Comment