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:
-
-
Add event test:
-
-
// For jquery:
-
-
for (var i=0; i <100; i++) {
-
$('#test').bind('click', function() { alert(this) })
-
}
-
-
// For prototype:
-
for (var i=0; i <100; i++) {
-
$$('#test').each(function (el) {
-
Event.observe(el, 'click', function() { alert(this) }, true)
-
}
-
)
-
}
-
-
(NOTE: could have used the new $(el).observe('click', function() {...}) syntax)
-
-
Add class test
-
-
// For jquery:
-
for (var i=0; i <1000; i++) {
-
$('.test').addClass('another')
-
}
-
-
// For prototype:
-
-
for (var i=0; i <1000; i++) {
-
$$('.test').each(function(el) { Element.addClassName(el, 'another') })
-
}
-
