This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I am more a ocasional java script developer. As I understood the debate so far, jQuery is very good for a certain task (traversal of DOM). Now if in my team, there is relatively much experience with Prototype, is it advisable (or even possible) to mix the 2 libraries? That means more specifically: Using prototype for ajax stuff and jQuery just for the complexer dom-access bits? Or qualifies mixing prototype and jQuery as a particularly bad idea and jQuery should be used separated from prototype for projects, where more advanced dom access is expected?
I'm currently using both in a project. Not because I want to but because I had to. Since both libraries use the $ function the only thing you need to do is make sure you tell jQuery to release control of that function by calling:
somewhere before all your other scripts run. That will tell jQuery to ignore the $ function so that prototype (or some other library) can use it. Then you just need to use jQuery.foo instead of $.foo for all your jQuery functions.
Personally, I prefer jQuery to prototype for everything; AJAX, DOM traversal. I just really like jQuery's approach to the problem and its extensibility. Granted, I haven't peaked that the very latest prototype release (1.6 I think) but as of 1.5 I believe JQuery to be a much better library.
Indeed, jQuery goes out of its way to make sure that it plays well with others.
Unlike most other libraries, its global name incursion is limited to two identifiers: jQuery and $. And as Gregg reported, the latter can be unbound in a supported fashion through a call to $.noConflict(). Now that's friendly!
Also like Gregg, I also find jQuery's Ajax support to be more intuitive and less wordy than Prototype's and use jQuery exclusively for my personal and client projects. In my day job, we use Prototype for a bunch of things and so, like with your project, the two libraries are sometimes used on the same page.
Because of jQuery's non-invasiveness, this is never a problem. [ January 15, 2008: Message edited by: Bear Bibeault ]