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?
- Developer ease of use
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.
- Developer involvement
- (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.
- 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.
- OO is non-existent (or unintelligible)
- (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’) ?
- 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.
- 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.next(); // 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.