• Home
  • Blog
  • Removing useless jQuery scripts in Joomla

Blog

Removing useless jQuery scripts in Joomla

By default, Joomla core and other 3rd-party extensions loads bundled jQuery from JUI:

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

Additionally, with /media/jui/js/jquery.min.js two more scripts are always loaded:

/media/jui/jquery-noconflict.js
/media/jui/jquery-migrate.min.js

But if your website doesn't use old deprecated MooTools and there are no issues with JUI version of jQuery (v1.12.4), you can disable loading of these extra scripts to reduce the number of requests.

Just pre-load jQuery framework with the scripts disabled:

JHtml::_('jquery.framework', false, false, false);

Add this code before the component is dispatched, i..e before the system plugin class declaration or use the onAfterRoute event.

Additionally, you can remove these scripts right in your Joomla template by unsetting the elements from JFactory::getDocument()->_scripts array referenced as $this->_scripts in template's index.php file.

jQuery, Optimization, Assets

Need Help?

If you are in need of help or have any questions regarding our products you may use one of the links below:

Our Newsletter

Get the latest news, product updates and special offers!

Copyright © 2009-2020 AlterBrains.com
Trademarks and tradenames used herein are the property of their respective holders.
The Joomla!® name is used under a limited license from Open Source Matters in the United States and other countries. AlterBrains is not affiliated with or endorsed by Open Source Matters or the Joomla! Project.