Moving $scripts to the bottom of your theme html

(2 minute read)

Per Yahoo it’s best to move your Javascript calls to right above your closing body tags since downloading scripts block parallel downloads which causes your page to take longer to download/render. (1) Now I’m not going to go into any metrics to prove this statement, we’ll just have to take Yahoo’s word on it.

In Drupal moving the print of $scripts to the bottom of your document is fairly straight forward. You literally just find in your page.tpl.php where you have your print $scripts; and move that further down in the document down to above the print $closure;. That’s it, no additional modules, no crazy theme overrides. If you’ve never worked in PHP then i would recommend you find someone to do this for you since you do have to get into the nitty gritty of your theme.

Before you go off doing any crazy changes please be sure to do this in a test environment and not on your production site just in case it breaks something. So far I haven’t found any problems caused by the move in core Drupal. Now your mileage may very due to what modules you use. So far I’ve found that TinyMCE doesn’t have the enable/disable button under text fields but that’s the only module I’ve found so far that causes issues.

(1) http://developer.yahoo.com/performance/rules.html

Categories: