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-git.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
- Revision 3: published
- Revision 4: published
- Revision 5: published
0 comments