Drupal: Mootools vs. JQuery

The designer I work with has a pretty long list of prewritten code that he knows to adapt in certain situations to create, for example, certain types of dynamic menus. In the basic HTML mock-ups that he likes to put together he therefore includes these so I’ll get an idea of what he wants to get done. This way we’ve encountered a problem though since Drupal doesn’t always behave very well when Mootools (added) and JQuery (native) are trying to coexist.

From some searching I’ve found that you can use JQuery function noConflict() and customizing all .js files that uses JQuery to get them to behave well together. This though creates some problems with updating modules or core since you’ve hacked them. Therefore I consider it an Ad Hoc solution that should be avoided whenever possible.

That leaves me with the task of rewriting all the Mootools code that the designer has gathered over the years in JQuery,  which isn’t perhaps the most fun solution but a more solid one and also forces me to really understand the code I’m putting into the website.

Is this the best solution, or are there advantages in using Mootools on your Drupal site that I’ve missed? Feel free to enlighten me! :)

Update:

From the comment below I’ve realized that it’s now also possible to wrap Mootools code so that it doesn’t break your JQuery code, which makes it easy to add some Mootools code to the site. The drawback is the performance penalties from using two libraries, but for small websites it’s a great working solution.

Update 2:

Adding Mootools code still breaks certain modules (like Panels, IMCE file upload and so on) so there really is too much trouble to be worth the effort trying to implement it.

Advertisement

4 Responses to Drupal: Mootools vs. JQuery

  1. Ken Marfilla says:

    Mootools is capable of everything jquery can. If you insists on using jquery, then wrap the mootools code inside a closure so you don’t have to port the already working codes.

    (function($) {
    //mootools code here
    })(document.id);

  2. Freddie Karlbom says:

    Are you speaking in the general sense or specifically for Drupal sites? The impression I’ve gotten is that most contributed modules as well as core use some JQuery and that it therefore is a better way to go with JQuery only.

    For the discussion of JQuery vs. Mootools in a general sense I’m not experienced enough in the latter to have an opinion.

  3. Freddie Karlbom says:

    Thanks btw. for the wrapping method for Mootools, I’d missed that option which will do the trick on the page I’m currently working on.

  4. [...] Drupal: Mootools vs. JQuery March 2010 3 comments 4 [...]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.