selector test

JavaScript performance comparison

Revision 18 of this test case created by Emil

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>

<div id="content">
        <form method="post" action="/">
                <h2>Traffic Light</h2>
                <ul id="traffic_light">
                        <li><input type="radio" class="on" name="light" value="red" /> Red</li>
                        <li><input type="radio" class="off" name="light" value="yellow" /> Yellow</li>
                        <li id="lightGreen"><input type="radio" class="off" name="light" value="green" /> Green</li>
                </ul>
                <input class="button" id="traffic_button" type="submit" value="Go" />
        </form>
</div>

Preparation code output

Traffic Light

  • Red
  • Yellow
  • Green

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Direct ID
$('#lightGreen');
pending…
Nested ID's
$('#traffic_light #lightGreen')
pending…
ID - Class
$('#lightGreen .off')
pending…
Class
$(".off")
pending…
ID - PlainJS
document.getElementById("lightGreen")
pending…
ID - Class PlainJS and jQuery
$(document.getElementById("lightGreen")).find(".off)
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