Selectors-By-Id

JavaScript performance comparison

Test case created by Michael Alt

Preparation code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<ul>
<li id="item-1">Item 1</li>
<li id="item-2">Item 2</li>
<li id="item-3">Item 3</li>
</ul>
    

Preparation code output

<ul> <li id="item-1">Item 1</li> <li id="item-2">Item 2</li> <li id="item-3">Item 3</li> </ul>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Pure DOM
var elt = document.getElementById('item-2');
pending…
jQuery
var elt = $('#item-2');
pending…
Selectors API
var elt = document.querySelector('#item-2');
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

Compare results of other browsers

0 Comments