views:

1665

answers:

3

Hi All, I know that jQuery.noConflict() is used to avoid conflict between $ of any other library and jQuery.(i.e. Prototype) But lets say, by any chance I am using Prototype, MooTools and jQuery.In that case jQuery.noConflict() will work fine for jQuery and any other library combination, but then what with Prototype and MooTools, if they both use $, how come code /browser will identify it properly. Note:I have never worked with Prototype and MooTools , so I am sorry if my question doesn't make any sense.

+1  A: 

If these other frameworks don't have something corresponding to the noConflict option, the last loaded of these frameworks will overwrite the definition of $ with their own, and the first loaded framework will be broken, if they both depend on $

David Hedlund
Thanks, for the info.
Wondering
You could study how jQuery implements noConflict and apply it to the the moo sources and contribute it back to the community. Ditto for prototype.
Jeff Paquette
that's an excellent suggestion flyfishr64 =)
David Hedlund
+2  A: 

Please check this out:

http://mootools.net/blog/2009/06/22/the-dollar-safe-mode/

Guillermo Rauch
A: 

Normally mixing two libraries is strongly discouraged. Not only due to potential conflicts, but due to the excessive overhead and performance implications. Mixing three would obviously be even worse.

The best solution to this problem is to take one or more frameworks out of the equation. Anything you can do in jQuery can be accomplished in Mootools and vice versa. Anything written on Prototype can be ported to jQuery or Mootools fairly trivially as well.

jmking