11

I just inherited some web pages which uses MooTools. I never used MooTools. Now I need to add some functions on the page, I wonder if it's a good idea to use jquery and mooTools on the same page?

Basically, I have 3 options,

  1. Convert the pages to JQuery, which I have to learn MooTools to do that.
  2. Write new functions in MooTools. I have to learn even more MooTools to achieve this.
  3. Use both on the page.

Your opinion will be appreciated.

9 Answers 9

46

Opinion: Learn MooTools and then move on with it. Sounds like a great opportunity to learn something new. Why introduce an entirely new library with addition js bloat if you don't need to. If it'll solve the problem you're golden.

1
  • 5
    Either you sully the project with JS bloat or learn MooTools. MooTools is kind fun anyway.
    – Ben S
    Commented Oct 2, 2009 at 15:19
16

MooTools is a perfectly solid and acceptable Javascript library and I'd recommend you add it to your list of known technologies rather than tear it out and replace with JQuery. Mixing the two is not a good idea as you're likely to encounter obscure difficult to debug conflicts.

JQuery has had all the press of late, but it's by no means cut and dried that it beats every other library hands-down. Far from it. You might even find you prefer MooTools :-)

ADDED: For what it's worth my personal experience is that MooTools seems to play alongside other javascript code more nicely than jQuery. I've been handling several sites of late which have mixed in MooTools with various other pieces of Javascript for different effects/functionality and it's all seemed to play along together with minimal issues. OTOH pages that use jQuery tend to use jQuery versions of everything. YMMV of course.

1
  • 4
    To comment on my own answer, whilst I think this was true in Oct 09 the ongoing rapid development of jQuery and it's widespread acceptance as the standard library over the last 18 months of so has tipped the balance now and I'd be more inclined to go towards a rewrite, depending on the size of the project. But I would still in no circumstances use both.
    – Cruachan
    Commented Nov 7, 2011 at 13:34
7

Personally, I'd recommend not using both, as there are strange conflicts, even with jQuery.noConflict(). Go with one or the other.

If you do end up using both, be sure to use jQuery.noConflict() to ensure that using the $ doesn't conflict.

Using jQuery with Other Libraries

4
  • 1
    can you elaborate on the conflicts, even when using .noConflict()?
    – Russ Cam
    Commented Oct 2, 2009 at 15:20
  • I've found that conflicts happen most often when attaching load events to elements that are high in the heirarchy. e.g. window or document load events. If you have some in MooTools and some in jQuery, you get unexpected behavior from both.
    – Marco
    Commented Oct 2, 2009 at 15:43
  • Marco's example is good example of a conflict that can happen. Attaching events from both libraries can cause weird issues where one of the library's events will trigger and the other's won't.
    – S Pangborn
    Commented Oct 2, 2009 at 21:28
  • Mootools also has a solution to the $ conflict issue (which I forget the details of). Still, don't add jQuery to the website. Just learn Mootools. It is fun. Commented Oct 2, 2009 at 21:57
7

i'd say, depends on how the code is structured and what you need to do. mootools does render itself to easy refactoring and extending (this is, after all, partly the reason it exists) but it takes a while to figure best practices and so forth.

however, your learning curve from vanilla javascript or jquery won't be too steep, especially so if all you care about is DOM mantipulation, event handling and effects. things get more interesting when you decide to write / extend mootools classes and venture into prototyping - but you may not have to do that...

there are some pretty good tutorials around for most things as well as some demos on doing things through jquery and mootools (equivalent ones). http://jqueryvsmootools.com/ is a good example on how the same task can be done through either one, i'd recommend reading it before deciding.

whatever you decide, it is a bad practice to use two frameworks (when you can do without).

6

It depends on how big a project it would be to convert to jQuery, how much of your job is maintaing these pages (vs other pages that already use jQuery), what the urgency is for your first set of changes, etc...

It comes down to a cost comparison: how does the cost to your business to convert them to jQuery compare to the cost to the business for you to learn mooTools (and maybe keep both mootools and jquery in your head at the same time).

The only thing I can say for sure is don't do option 3. This isn't necessarily because it you can't make it work (and there will be challenges), but because you'll have to learn mootools to properly maintain the pages anyway. Once you do that, you may as well just keep them mootools rather than re-write everything or try to mix frameworks.

Personally I'm inclined to say convert it jQuery, since I believe jQuery is eventually going to corner the market. The implication then is that it will convert to jQuery at some point, and so the long term costs to business are probably best optimized by doing the conversion earlier while there's less to convert and mootools is still relevant so you can easily get help with the conversion. But that's certainly arguable.

3
  • I like Joel's thoughts on this - do not do option 3, go with jQuery if you're comfortable with jQuery and have the time/budget to do the conversion. If it's going to be a pain, I'd suggest learning MooTools, because chances are, you'll run into this again one day - and you'll be a stronger developer understanding the basics of both MooTools and jQuery.
    – keif
    Commented Oct 5, 2009 at 7:07
  • 2
    jquery cornering the market? may be so but it's not in the same market as mootools--it really offers nothing on top of vanilla javascript to handle class based inheritance. mootools is not going anywhere - it's here to stay and with ver 1.3 and 2.0 looming on the horizon, it will only get stronger... Commented Dec 17, 2009 at 10:25
  • @Dimitar Christoff: my experience with large-scale javascript programs based on "classes" suggests it's a wrong approach. Commented Dec 17, 2009 at 18:18
4

jQuery and Mootools basics are close enough that moving from one to the other isn't much of a headache.

Whenever I'm given the choice between the two, I lean towards Mootools - especially if I'm intending to do any sort of effects or animations. Mootools's base FX libraries are far more robust and generate better results cross-browser in my experience.

Like others have suggested, you could take this opportunity as a learning experience. If you're satisfied with jQuery and don't feel the need to learn another framework, port the code over. You can't really go wrong with either in the end.

3

Since you're more comfortable with jQuery, I would just call jQuery.noConflict(); first thing, and write the functions in jQuery. That is, of course, if time is a factor.

2

There is a project that twists and prods Mootools to make it look like JQuery (a wolf in a sheep's clothing... or a golden coin painted to look like silver...)

I certainly think you should learn Mootools, but that might help.

1

I agree with those that are in favor of learning mootols, but i think that is even better if your take that decision because you finally think that learning mootools worth it.

So i think it would be nice to have some research over mootools capabilities.

I like this articule about this subject. And I think it can be useful for those reading this thread.

http://jqueryvsmootools.com/index.html

Not the answer you're looking for? Browse other questions tagged or ask your own question.