You’ll often find yourself using frameworks that may be running a number of different javascript libraries such as MooTools, jQuery and ProtoType (depending on the various involved developers’ plugin preferences of course), which leaves you with the interesting quandry of what to do with the shared $ variable that most libraries tend to have a different use for.

Thankfully though, jQuery comes bundled with a nifty little function to deal with this hassle for us.

jQuery.noConflict() is a function that when run, gives control of the $ variable back to whichever library first implemented it. Of course, once run you do need to change your approach to calling jQuery magic by using the jQuery variable, for example where you might have in the past used $(‘div p’) as a selector, you would now have to replace it with jQuery(‘div p’).

The jQuery.noConflict function must be called after including the main jQuery javascript file but before including any other conflicting library, as well as before any other conflicting library does actually get used. Interestingly enough though, you can actually make the function call right at the end of the main jQuery.js file itself, to globally disable the $() jQuery alias across the site.

Useful eh?

Related Link: http://docs.jquery.com/Using_jQuery_with_Other_Libraries