29Oct2015
Information
Print

Making the cut with jQuery and MooTools in Joomla: Introduction

Information
jQuery
First published August 22, 2011
6542 hits -
 

The library MooTools has been chosen by the Joomla! development team as its javascript framework by default. That decision was made years ago, when just a few libraries were available and the web 2.0 hype started to heat up. MooTools is now part of the project and is essential to run Joomla!.

As years have passed, jQuery has become one strong contender in the framework world and more and more developers choose it in the creation of extensions for Joomla!.

Can these two libraires co-exist together? Yes, they can. MooTools is prototype-based, not jQuery. Nevertheless, in order to use them both in Joomla, either on the administration side (back-end) or the site side (front-end), a few precautions are necessary:

  • MooTools has to be loaded BEFORE jQuery,
  • the declaration jQuery.noConflict() has to be used for the jQuery code. From that time on, jQuery is used in place of $

Although impossible to remove from the back-end (Joomla uses the framework extensively for its core functionning), the MooTools library could be excluded from the front-end. Such a removal requires an inside look at all modules, plugins and templates which could eventually use it. Therefore, I suggest NOT TO remove MooTools and rely on the noConflict() method.