Prototype vs. jQuery

Okay, I was wrong. I had at one time mocked jQuery as a the javascript equivalent of PaintShop Pro or Fireworks. Something light, but not something you would use for enterprise level work, and not something that would hold it’s own against Prototype.

I was wrong.

For the past few months, jQuery has been knocking my socks off with it’s awesomeness. Don’t let it’s ease of use fool you. It’s got some heavy duty-ness to it that isn’t fully appreciated. I am now actively pushing it in all of my projects, as well as at work in an enterprise portal/CMS.

Why? What was the deciding factor for me over Prototype?

  1. Developer ease of use
    When you’re starting out in web development, it’s hard enough to get HTML and CSS down, and Javascript can seem like a real burdensome beast. By leveraging CSS knowledge, jQuery is finally bringing the power of Javascript to those folks.
  2. Documentation
    This has long been an issue in the Prototype community. While people are making inroads, nothing can compare to jQuery’s available documentation/blogs/tutorials, etc.
  3. Plugins
    Justin seemed to poo-poo this a bit a while back, saying that Javascript is easy enough to plug into, and I think the difference is that jQuery has implemented a formalized API spec that makes it easy. Yes it’s easy to do in Javascript, but that doesn’t mean it’s easy for everyone.
  4. Developer involvement
    I just get the feeling that Prototype is more of a side project that Sam Stephenson deigns to be involved in when it suits him, where as I truly get the feeling that John is passionately in love with Javascript and is deeply committed to the project and treats it AND the community with a lot of respect.
  5. (Fairly) centralized activity
    It’s VERY easy to find large groups of people who are in love with jQuery and use it extensively. Prototype has a lot of use but finding large communities around it and dedicated to it is harder.
  6. Lots of activity
    All of this centralized activity makes it MUCH easier to not only get introduced to jQuery, but to also identify and solve problems that popup. It also helps get bugs resolved very quickly.

Now, what issues do I have with jQuery? There are a few, coming from a Prototype background, and some things that don’t make sense to me. Now, admittedly, I could be wrong about them, but if so, I would love to have some feedback.

  1. OO is non-existent (or unintelligible)
    I want to write Object-Oriented Javascript and I want it to be easy. When I create an object, I want to be able to set what "this" points to. Does it point to the calling object, does it point to the clicked item, etc. Prototype handles this well by allowing you to set the object via "bind" (eg. JSObject.add(‘param’).bind(obj) and inside of JSObject’s add method, "this" points to obj rather than to the JSObject class). I would love to find a way to easily control this and know this inside of an object.
  2. (Re-)Setting an elements class is retarded
    Almost everything else in jQuery has a very easy to remember function for setting attributes such as src() for image sources href() for link href’s but why is it to set an element’s class or completely reset it, I have to do this: element.removeClass(‘currentClass’).addClass(‘newClass’) ? Why not element.class(‘newClass’) ?
  3. No forums
    I have heard this is in the works, but honestly, I will buy the domain and even pay for the vBulletin license if we could get this officially out there sooner.
  4. Element confusion
    This is something I am sure just takes some getting used to, but it would be nice for us Prototype developers to grasp if it was explained and detailed somewhere (it might already be, though). I’ll give an example:
    var el = $('#element_1'); // Points to element_1
    var el2 =; // el now points to the it's sibling rather than returning the next object

    Now, as I understand it, the way to return the sibling to el2 is to do this:

    var el2 = $(el).next(); // el2 now points to the sibling and el points to the original

    For me, that’s hard, because everytime I use $() I feel as if there goes one more performance hit. Now, jQuery could be optimized for it, but it makes me panic something fierce, as I want to have very lean code, and having extraneous function calls hurts my delicate sensibilities.

Overall, though, jQuery is turning out to keep hitting that perfect sweet spot for me. I will also love prototypes wonderfully elegant object oriented look, but at the same time, jQuery is rocking my boxers off.
The only thing that could make me happier is if jQuery started implementing some very Prototype like functionality.

P.S. You’ll notice I didn’t mention anything about jQuery’s XPath or CSS 3 support, but it is by far one of the coolest freakin features around. Also not mentioned, but worth mentioning here is jQuery’s speed vs. Prototype’s $$() function.

2 comments to “Prototype vs. jQuery”

  1. Rick

    Nice comment form…

    I would like to comment on Issue #2, about the class "reseting". Why are you treading classes as if they are ids? The point of classes is that they can be reused by multiple elements, and an element can have multiple classes. Not just one.

    If you think like that, jQuery actually does a great job following the CSS standards.

    Issue #3: yes jQuery really lacks a real user forum. Currently they have one at, but admittedly, it sucks compared to other boards. You could check it out though.

    I really love your websites appearance..

  2. ian

    what was your workaround for the lack of bind in jquery?  i need bind to process my ajax calls correctly.  ie: i need the callback from one method in an object to be another method in an object.  that lack of bind in jquery is the main thing keeping me from switching.

Comments are closed.