WordPress 2.0 essentially marked the final leap of the WP team in joining the Web 2.0 bandwagon… We have a big friendly typeset, drag-and-drop widgets, AJAXified posting and moderating tools. And with 2.1, we will be getting a JavaScript framework.
This doesn’t mean much to the average WP user, but to developers, its huge. Every time a WordPress blog loads, the viewer is now downloading a 48kb nugget of JS - the Prototype Framework. So as a developer - if I want to make a shiny 2.0′ish plugin, I’ve got to use Prototype as a backend. Or I have to force everyone to use something else, of questionable compatibility, which will add yet more bulk to WP. Alex King has embraced Prototype with his Share This plugin. I’m sure others are soon to follow. But to be honest, I can’t see why the whole community isn’t throwing a colossal fit and threatening to dunk the WP dev team in a nice cold lake.
I admit, I’m biased. I’ve been developing sites with the JQuery framework for 4+ months now. Back in August of 2006 I realized that all this AJAX/2.0/Rails/Blah nonsense wasn’t going to fade away, so I best bite the bullet and learn what all the hype was about.
So I looked at Prototype, Scriptalicious, Ruby, Rails, read about AJAX… posted a forlorn “help me, i’m drowning…” message on the Apple web dev mailing list, and got one very short reply: “JQuery. I’ll see you on their dev list soon :)”
Prototype does some nice things for you, don’t get me wrong. But Prototype on its own still requires a lot of down-and-dirty javascripting PLUS a learning curve of Prototype syntax, functions and classes. Ick. JQuery, however, does many simple and not-so-simple tasks for you with only a line or two of code. Sure, there’s a learning curve, but at least there is a nice juicy carrot at the end. I don’t want to do loads of down-and-dirty scripting. This is why I looked for a framework in the first place.
There are a variety of examples of how JQuery uses cleaner, more logical, shorter code on the JQuery blog itself. These are a little technical though, and I wanted to provide a quick glimpse that might be more relevant to Plugin Developers:
So you want to hide and show a div, and you want it to slowly fade in and fade out when you toggle the hide/show.
JQuery (library weighing in at 20kb):
Prototype (48kb on its own) can’t do this. We need to add Scriptaculous + Prototype, which has a combined bulk of 228 kb!
Okay… Other than the added size and extra includes, this doesn’t seem all that bad. But what if we don’t want to add an onclick=”javascript: blah” to every scripted element?
JQuery (20kb):
$(#ohmy).hide(”slow”);
return false;
});
Prototype (48kb on its own) can’t do this. Scriptaculous + Prototype (228kb) can’t do this either. We need Scriptaculous + Prototype + Behaviour, weighing in at 236kb
‘.toggle’ : function(element){
Effect.toggle(’ohmy’,'appear’);
}
}
};
Behaviour.register(myrules);
NOTE: As Nate pointed out, this is wrong. The $$(’.toggle’) function will work just fine. However, I’m leaving the Behaviour example up to illustrate what a fairly savy coder, new to ProtoType, was able to come up with in 2+ hours of research.
Doing something a little more advanced… odd/even ‘zebra’ tables without php overhead:
(this one was pulled from the JQuery blog)
JQuery (20kb):
Prototype (48kb):
$A(table.getElementsByTagName(”tr”)).each(function(row,i){
if ( i % 2 == 1 )
Element.addClassName( row, “odd” );
});
});
So… JQuery: Get stuff done with less code! For 1/11th the size of prototype+scriptaculous+behaviour, JQuery provides tons of USEFUL stuff built in, no need for additional overhead libraries.
That’s my perspective. I don’t *LOVE* to code for the sheer joy of it. I DO love to see my ideas and visions become reality. I like pretty gadgets, including those that are browser-based. I think this is where many of the WordPress plugin/extension developers are coming from - we want more shinys in our blogs! Thus far, WordPress has done a PHENOMENAL job of making plugin development simple, logical, and intuitive. I picked up WP Plugin syntax in about an hour. Why ruin the ease-of-extension movement now?
And if you want to try JQuery with WordPress… Head on over to Dan Atkinson’s site for his JQuery with WP Plugin
10 Comments so far
Hey there!
Thanks for the link!
I’ll be updating the plugin in the next few days to be compatible with jQuery 1.1a (7th), and then 1.1 (14th), so you’re welcome to come back then!
Either way, anything which makes sites look more usable and interesting through things like Prototype and jQuery is a bonus.
I just prefer jQuery because of it’s tiny size and the amazing community which has a knack of replicating almost every cool thing that Dojo has, and then some!
I’ll point to Thickbox as a prime example (something I also provide as a plugin! ;-)).
Bye for now!
Yes indeed, Thickbox is an awesome example. I’ve used it on a few my clients’ sites already with plans in the works to roll out several other impementations.
geekgrl.net ยป jQuery vs Prototype - WordPress Gone Astray…
…
While I have to agree with you, I would say your example of having to add behaviour.js is completely wrong.
Prototype has a function called $$() which you can use like so:
$$(’.toggle’)
Prototype is a great conceptual library, and while I think it does a great job of making Javascript look more like Ruby, I think jQuery will succeed in the end because there are more people who know CSS and want to use Javascript, than there are Ruby developers who want to use Javascript.
jQuery brings JS to the (web-dev)masses, whereas Prototype makes Javascript easier for Ruby programmers.
Not to crap on Prototype at all, though. It is a great library, but jQuery is superior, IMHO, and the reasons why I layed out here: http://www.alterform.com/news/prototype-vs-jquery
Nate: Thanks for the info, I guess I was referencing an older Prototype guide (Hrm, old and decentralized documentation…)
But I will willingly admit that I’m not a ProtoType buff. It seemed cumbersome - that’s why I went with JQuery. I do reasonably affordable high quality web work, so efficiency is everything.
I think you’re right about WP going astray. One of the devs who coded one of the most popular plugins for the program, and has worked on core, mentioned to me that the reason his plugin was causing problems with one of the recent releases of WP (I think the last one, not the most recent) was that WP had become way too bloated, and if you added plugin code on top of it then insult was being added to injury. Anything they can do at this point to shave overhead needs to be done before they add more features.
I agree with those who think putting Protptype into Wordpress is a mistake. I desparately hope there’s a way to disable this, and that not too many plugins come to depend upon Prototype… otherwise I could see a fork coming in the road for WordPress, based on the 2.0 code base.
If someone wanted to include Prototype in a theme– say, a richer version of Sandbox– that would be a different matter. But putting it into the foundation is mixing presentation and content too intimately.
I’m newer to the world of blogging than I care to admit–after an abortive attempt a couple of years ago, I launched my first serious blogs, including a couple of buisness blogs and a couple of personal ones, in the last 30 days. Wordpress plus Sandbox plus a collection of useful plugins I’ve found provide just about all the functionality I expect to need for the range of stuff I do. (The main remaining thing would be to create a set of scripts for cloning an existing “template blog” to make new blogs quickly.)
Since WP2.0 will be supposedly supported for a long time, I think I’ll just stay with it as my platform. I would really have to find something incredibly useful about WP2.1 to put up with Prototype.
Prototype is only really used for AJAX right now. We’ll probably be switching a lot of stuff to jQuery in 2.2. jQuery is already in trunk. Plugin and theme authors will still be able to request that prototype be loaded via the script loader. We’re not religious about what libraries plugin authors use.
I like JQuery. A day to learn is not that bad at all. But now Mootools is striking back. They have pretty nice features. I wish they all agree in one model and make it easier for us to integrate and build.
Leave a reply


So, you’ve finally shot XOOPs. JQuery? I guess I’ll have to check it out.