Place Your Script Tags at the Bottom
Author: Mitch Keeler
Want a quick and easy way to speed up your web site? Well, it might not work for everybody – but this is what I like to do.
If you can, place script tags at the bottom of a web page instead of the top. When calling a special tracking code, or using a special JavaScript file – give it a shot. Now why and how does this speed things up? Well web pages are loaded from top to bottom, and the loading can progress if it gets hung up trying to load (for example) your JavaScript file.
Moving it to the bottom, it will save that for last – and your user can enjoy checking out the rest of the page – just in case it gets hung up.
Something else you can do to speed up JavaScript files is to compress them as much as possible. Here are two great resources that will help you get that done:
Now with your scripts in the right spot and your JavaScript compressed for faster loading, you should see some speed boost in your web site’s performance.




February 25th, 2009 at 5:58 am
[...] Place Your Script Tags at the Bottom [...]
February 25th, 2009 at 10:39 pm
Putting the script at the bottom really is a two-edged sword at best. As an instructor, I always told my students to be mindful of the ordering of the scripts, and to put them at the top. In some cases, a script may work on the bottom, but it can also cause substantial headaches. First of all, modern HTML standards expect scripts in the tag rather than the tag to begin with. The main problem is the onload= attribute. If you do put a script at the bottom, it may not yet have been loaded when onload executes, and will error out. As a result, your page will not be initialized properly. The insidious thing is that this is impossible to test for. The site may work flawlessly when you test it over a DSL line – and error out for a visitor with dial up.
February 28th, 2009 at 11:22 pm
Placing 3rd party javascript includes at the bottom of the page results in very noticeable improvement when dealing with google scripts and anything third party.
As long as it does not need to be in the page onload or be instantiated prior to a web control / effect being rendered (ajax) like Kevin mentioned.
I have a common footer file (php and asp.net includes) and keeping track of 3rd party scripts is pretty easy with this method.