jQuery Multiple Selector Performance Problems
JavaScript performance comparison
Preparation code
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>
var jq142 = jQuery.noConflict();
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script>
var jq143 = jQuery.noConflict();
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script>
var jq151 = jQuery.noConflict();
</script>
<script src="http://code.jquery.com/jquery-git.js"></script>
<script>
var jqgit = jQuery.noConflict();
</script>
<div class="test" id="test">
<script>
var html = "";
for ( var j = 0; j < 20; j++ ) {
html += '<div id="bigdiv' + j + '">';
for ( var i = 0; i < 1000; i++ ) {
html += '<div class="find"></div>';
}
html += '</div>';
}
document.write( html );
</script>
<input name='testinput' type='hidden' />
<select name='testselect'><option>1</option><option>2</option></select>
</div>
<script>
var $jq142 = jq142("body");
var $jq143 = jq143("body");
var $jq151 = jq151("body");
var $jqgit = jqgit("body");
</script>
Preparation code output
<div class="test" id="test">
<input name='testinput' type='hidden' />
<select name='testselect'><option>1</option><option>2</option></select>
</div>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
Test | Ops/sec | |
---|---|---|
input,select - 1.4.2
|
|
pending… |
input,select - 1.4.3
|
|
pending… |
input,select - 1.5.1
|
|
pending… |
input,select - GIT
|
|
pending… |
input then add() select - GIT
|
|
pending… |
input only - GIT
|
|
pending… |
select only - GIT
|
|
pending… |
input then select - GIT
|
|
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.
- Revision 1: published Justin Seger
- Revision 2: published
- Revision 3: published John Papa
- Revision 4: published
- Revision 5: published
- Revision 6: published
- Revision 7: published
- Revision 9: published
- Revision 11: published
0 Comments