views:

307

answers:

1

I have written a site in Prototype but want to switch to jQuery. Any ideas on how best make the switch?

+7  A: 

Personally, I like to take things in steps, so I would start by using both, like this:

jQuery.noConflict();

// Put all your code in your document ready area
jQuery(document).ready(function($){
  // Do jQuery stuff using $
  $("div").hide();
});

// Use Prototype with $(...), etc.
$('someid').hide();

That way you don't have to convert all your old code at once, but can start using jquery on new stuff, and migrate your old Prototype code when ever it's convenient. I don't know the size of your project, so I can't say whether or not this applies to you, but Spolsky had a great article about "The big rewrite" and why it's such a bad idea in Things you should never do, Part 1. It's well worth a read!

For more on using jquery with Prototype, see Using jQuery with other libraries in the jquery docs.

Erlend Halvorsen
+1 I also think that article by Spolsky is a good one. And nifty use of .ready(function($){}), using $ as the argument name.
thomasrutter