Avoiding jQuery’s noConflict() Mode with Prototype and Sitecore
April 5th, 2010
Web Content Management, Web Development
The brevity of the Prototype JavaScript library’s $() (i.e. the “dollar” function) is without a doubt a handy tool and easy to type over, and over, and over again. It caught on quickly as JavaScript frameworks took off and John Resig’s jQuery library used a version of it from the start as well. Of course, this had issues where from time to time both Prototype and jQuery might show up on the same Web page.
The pros and cons of loading more than one JavaScript library over HTTP is of course a whole other article in and of itself. Please always consider the implications of such a move. It’s all about page weight and performance.
jQuery has been the JavaScript framework of choice at NavigationArts for quite some time. It has, for as long as I can remember, featured a method called noConflict() which returns control of the $() function to whatever it was previously defined as. What does that mean? Well, in jQuery, $() is just an alias to the jQuery object, so it removes that alias. It’s done this way: (more…)
Rob Cherny
