jquery selector speed

JavaScript performance comparison

Revision 51 of this test case created

Preparation code

<div class="container">
<div id="container">
    <ul>
        <li>The quick</li>
        <li id="target "class="target">brown fox</li>
        <li>jumps over</li>
        <li> the lazy</li>
        <li> dog </li>
    </ul>
</div>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
 
<script>
Benchmark.prototype.teardown = function() {
    $('#target').unbind('click');
};
</script>

Preparation code output

  • The quick
  • brown fox
  • jumps over
  • the lazy
  • dog

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
$('.container #target')
$('.container #target').css('border', '1px solid red');
pending…
$('#target')
$('#target').css('border','1px solid red').bind('click',function(){}).unbind('click');
pending…
$('.target')
$('.target').css('border','1px solid red').bind('click',function(){}).unbind('click');
pending…
$('':contains())
$('#container .target:contains(brown fox)').css('border','1px solid red').bind('click',function(){}).unbind('click');
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:

0 comments

Add a comment