Why I still love Prototype
by Naneau
There has been a lot of talk lately about how prototype.js is bad. The discussion usually focuses around the fact that it is rather large (~50 KiB) and modifies some behavior that some people have used in their scripts for years. While some of these discussion have valid points, I still think that they miss the point in general.
The size of prototype is an issue, it’s true. Especially as a lot of people out there don’t know how to serve JavaScript correctly.They just link to the uncompressed prototype.js file in their HTML head section and never think about it again. That is of course not the best way. It’s really easy to set up apache to use gzip for JavaScript and CSS files, and doing it from PHP is a breeze too. You could also compress the JavaScript itself, for instance using Dojo’s ShrinkSafe.
There are other techniques for serving javascript faster as well. I read an interesting article about using cnames to get around the standard 2 connections per server limit. It is what Google uses for Google Maps. I remember the amazement about it’s responsiveness when that came out.
Prototype does of course break a tiny bit of JavaScript behavior, like the for-in loop. It doesn’t break anything that it shouldn’t. It may be a bit of work to get it to work if you have a lot of legacy scripts laying around that you would still like to use. But for me, that’s not what prototype is all about. I love developing based on prototype, because it’s so much easier than any other JavaScript library I have ever used.
It’s documentation is such a good read. There was a time that JavaScript came without any documentation, at all. ScriptDoc tried to change that, but has failed to do so in my opinion. It’s all too common to see a new, hip, web 2.0 script, that doesn’t even come with inline comments. For people new to JavaScript decent documentation makes a big difference. Especially those that came to the JS world with OO-experience will love it.
I’m not a JavaScript expert, and I don’t think I ever will be. Maybe that’s why I love it. But isn’t that a valid reason? Prototype’s mission statement is that it makes JavaScript sucks less. It has done that for me. I now feel confident about developing in it, and I enjoy creating fun little projects based around it. I still love prototype.
Comments
I haven’t done much yet with any of the popular JS frameworks, but I’m planning to start soon. At this point, I’m still on the fence between Prototype and jQuery. Hearing that WordPress plans to migrate all its JS to jQuery is causing me to lean in that direction as well. Do you have any jQuery experiences you could tell us about? Thanks.
As far as I know, jQuery is a beautiful framework as well. I can’t say that I’ve been beyond the ‘checking it out’ phase.
It is second level though. Where prototype does some things it’s own way, jQuery is a collection of tools that help you code with more ease. I don’t see anything that could stand in your way when trying them both. I’m sure personal preferences play an important part when deciding between the two.
Wordpress has only migrated in name. Only very few things in 2.2 use jQuery yet, and there’s some discussion about why the move was necessary. jQuery is not that much smaller than prototype.