pCloud Premium

Joomla JavaScripts files in the bottom of the page

Joomla JavaScripts files in the bottom of the page

By visiting a web page, your web browser starts downloading all the files/elements in it. Usually that happens in the order in which they are enrolled. So putting the JavaScript files in the top - <head> of the page, can lead to delays in the visual loading of the site. Oftenly scripts are much larger in size than .css or graphics. So if the browser loads the .css files and graphics first, we'll have the effect of faster loading website. Here's how we do it in Joomla!

This tutorial is for version 1.5

Joomla uses <jdoc:include type="head" /> tag in <head> section to dynamically display javascript and css files needed for the site. The file responsible for this is in: librariesjoomladocumenthtmlrendererhead.php and this is where we'll work on the case. Copy the file head.php and rename it as bottom.php Now open head.php file and delete text from line 128 to 150.

Now open the file bottom.php and delete text from line 63 to 126.

Now open the index.php file of your template and paste this tag <jdoc:include type="bottom" /> just before the closing </body> tag. Now the JavaScript files are loaded automatically at the end of the page. ico

But sometimes you may need to have a specific JavaScript file in the <head> section. In this case, you can call it manually:

  1. <script type="text/javascript" src="/<?php echo $this->baseurl ?>/templates/вашият_темплейт/javascript.js"></script>

I hope the lessons was useful ico

23 March 2012г.
Viewed 6428 times