attr vs attrhooks
JavaScript performance comparison
Info
Compares the performance of attrhooks vs the old attr
Preparation code
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.js"></script>
<script>
var oldAttr = jQuery.noConflict();
</script>
<script src="http://code.jquery.com/jquery-1.6.js"></script>
<script>
var newAttr = jQuery.noConflict();
</script>
<div id="testDiv"></div>
<input type="text" id="someInput" value="foo">
<script>
var oldDiv = oldAttr('#testDiv'),
oldInput = oldAttr('#someInput'),
newDiv = newAttr('#testDiv'),
newInput = newAttr('#someInput');
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
oldDiv.attr('id') |
|
pending… |
newDiv.attr('id') |
|
pending… |
oldInput.attr('value') |
|
pending… |
newInput.attr('value') |
|
pending… |
oldDiv.attr('class', 'wowzers') |
|
pending… |
newDiv.attr('class', 'wowzers') |
|
pending… |
oldInput.attr('foo', 'bar') |
|
pending… |
newInput.attr('foo', 'bar') |
|
pending… |
Compare results of other browsers
Revisions
You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:
- Revision 1: published by timmywil and last updated
- Revision 2: published by timmywil
4 comments
It seem good!!
sdfdfss
Without standardized hardware, these rsults are skewed at best. Of course Safari will score better in most tests, it ships with some of today's fastest desktops and laptops. Do you really expect Chrome 12 on a PC with E5700 and DDR2 to be as fast as Safari on E7600 and DDR3?
This isn't to compare across browsers really (You can run the tests on your machine in the range of browsers you care about) it is more within that browser which version is faster.