Remove JavaScript Frameworks From Your Joomla! 3.2 Template

02.07.2014
Remove javascript frameworks from Joomla

This for all of you Joomla! 3.2 Template developers out there. Yes, you.

If you’re like us and use Bootstrap in your templates, you’ve probably run into issues where MooTools More & Bootstrap.js don’t play nice.

By default, Joomla! loads a bunch of javascript files that you may not need or want in your template. For many reasons, you’re probably looking for a way to remove them, right?

Here’s a snippet of code (shoutout to this Joomla! Forum post) that we use in some of our templates to remove unwanted JS files:

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

Just be sure that this code is somewhere before your <jdoc:include type=“head” />.

Additionally, you may want to remove the calls to the JavaScript frameworks from within certain layout files. For instance, by default the mod_finder layout includes Mootools on line 14:

JHtml::_('behavior.framework');

To remove them, create an override in your template and remove the line. Obviously, this will make certain functions in the module, well, not function.

The same can be said for removing JavaScript frameworks in general; if you remove one, it could potentially break something that you didn’t know you needed. It’s safe to assume that most of the core Joomla! modules/components will need MooTools in some capacity—so if you’re removing these frameworks, make sure you know what you’re doing.

Also, one more word of caution: DO NOT MODIFY CORE JOOMLA! FILES. One of the benefits of using Joomla! is output overrides—using overrides will prevent you from overwriting files that could potentially change when the site gets upgraded to a newer version of Joomla!.