Stop Loading Javascript Files through Joomla Templates

As a template developer, sometimes is good to know some tricks to make a template lighter.
If you consider one or more Javascript files are not relevant to your Joomla site, you can remove them.
Continue reading to find out how!

Note: there is no guarantee this trick will always work; use it with caution.
Which file you want to stop loading?
Visit your site and check the source code.
You can do this with right click > “View page source” or similar. You can also use Ctrl + U keys in Windows.

Let’s say I want to remove mootools-core.js script from source code.

Important: if you’re using a template developed by someone else that may get updates in future, is good practice to duplicate it and work over your copy instead.

Edit your template by going to:

  • Extensions
  • Templates
  • Templates (on the left side)
  • Your Template Details and Files

Edit index.php, and add this line of PHP code at the top:

unset($this->_scripts[JURI::root(true) . '/media/system/js/mootools-core.js']);

Replace '/media/system/js/mootools-core.js' with the relative path of the file you want to stop loading.

Click save & close when you’re done.

End result

Refresh your public site and check again the source code.

If everything is correct, the Javascript file won't be loaded anymore.

Back to Blog

loading...
Make an appointment+44 7765 119 293
Send us a messageoffice@fifwebstudio.com
Visit usSW11 4DQ, London