Unload Joomla Scripts - Mootools, JQuery, Bootstrap From Loading

Joomla loads a bunch of scripts by default - many of these are necessary for something or other, but sometimes (if you know what you are doing) you may want to remove them or stop them from loading.

To do this, there is a specific function that you can use. Add the following to the index.php of your template.


Manual Code

Add or remove files from the dontInclude - the ones you add here will be unloaded. Anything which you do not include will not be unloaded.

$doc = JFactory::getDocument();

$dontInclude = array(

foreach($doc->_scripts as $key => $script){
    if(in_array($key, $dontInclude)){

Joomla Plugin To Unload Scripts

There are quite a few plugins that allow you to remove such scripts if you don't want to include them. We use the Mootools Enabler / Disabler plugin by Roberto Segura which is tiny plugin, which unloads the plugin from everywhere except the places where it is required.

For example, you can choose the Auto enable the scripts for the users' login and for article addition.

We also use the same plugin to unload other stuff that we want to exclude by simply adding the URL of the JS file we want to exclude:

mootools enabler disabler

As you can see, we're dropping infinite scrolling and pagination scripts which are included by default in our template, but which we do not need - and would just add page loading time literally for nothing.

We're also dropping the ionicons CSS, which once again would just be unnecessary bloat.

In our quest to bring our site to load in as few milliseconds as possible, this tool has been a great addition.

Another alternative whose setup is a little more complicated is jQueryEasy. This is much more configurable, but usually makes sense in the hands of a developer who os very comfortable with Joomla.



About the Author
David Attard
David has been working in or around the online / digital industry for the last 18 years. He has vast experience in the software and web design industries using WordPress, Joomla and niches surrounding them. As a digital consultant, his focus is on helping businesses get a competitive advantage using a combination of their website and digital platforms available today.

One more thing... Did you know that people who share useful stuff like this post look AWESOME too? ;-)
Please leave a useful comment with your thoughts, then share this on your Facebook group(s) who would find this useful and let's reap the benefits together. Thank you for sharing and being nice!

Disclosure: This page may contain links to external sites for products which we love and wholeheartedly recommend. If you buy products we suggest, we may earn a referral fee. Such fees do not influence our recommendations and we do not accept payments for positive reviews.


who are we?

CollectiveRay is run by David Attard - working in and around the web design niche for more than 12 years, we provide actionable tips for people who work with and on websites. We also run DronesBuy.net - a website for drone hobbyists.

David attard



Author(s) Featured On:  Inc Magazine Logo   Sitepoint logo   CSS Tricks logo    webdesignerdepot logo   WPMU DEV logo   and many more ...