Claudio Cicali thinks benchmarks are boring and useless, so he decided to conduct a series of micro-benchmarks of CSS selector tests with both Prototype and jQuery. He decided to do this after he saw others observe:

  • Prototype (1.5+) has CSS selector syntax now
  • "jQuery is horribly SLOW"

Some Examples

JAVASCRIPT:
  1.  
  2. Add event test:
  3.  
  4. // For jquery:
  5.  
  6.     for (var i=0; i <100; i++) {
  7.       $('#test').bind('click', function() { alert(this) })
  8.     }
  9.  
  10. // For prototype:
  11.     for (var i=0; i <100; i++) {
  12.       $$('#test').each(function (el) {
  13.         Event.observe(el, 'click', function() { alert(this) }, true)
  14.       }
  15.       )
  16. }
  17.  
  18. (NOTE: could have used the new $(el).observe('click', function() {...}) syntax)
  19.  
  20. Add class test
  21.  
  22. // For jquery:
  23.     for (var i=0; i <1000; i++) {
  24.       $('.test').addClass('another')
  25.     }
  26.  
  27. // For prototype:
  28.  
  29.     for (var i=0; i <1000; i++) {
  30.       $$('.test').each(function(el) { Element.addClassName(el, 'another') })
  31.     }
  32.  

jQuery Prototype Benchmark