Prototype vs jQuery
I chose jQuery over Prototype as my framework of choice a long time ago and have found little reason to look back. Today I started working on a project that uses Prototype. This is my first time in a long time using Prototype. I just spent the last hour translating this 3-liner from jQuery to Prototype. I’ve written procedures very similar to this at least a dozen times for navigation lists on various other projects, so the original 3-liner literally took less than 20 seconds to write. If that.
Here it is in jQuery
$('#twelvesteps ul.nav a').click(function(){ $(this).addClass('active').siblings().removeClass('active'); });
And here it is in Prototype
$$("#twelvesteps ul.nav a").each(function(el, index){ el.observe('click',function(e){ var li = el.up(); li.addClassName('active'); li.siblings().each(function(el2, index){ el2.removeClassName('active'); }); }); });
And you know what? It’s slow. It takes like a hundred milliseconds to switch the classes. WTF.
Comments(0)