querySelector id vs class

JavaScript performance comparison

Test case created by rhapsodyn

Preparation code

<div><div></div></div><div><div></div></div><div><div></div></div><div><div><div><div></div></div><div><div></div></div><div><div></div></div><div><div></div></div><div><div></div></div></div></div><div class="c" id="i"><div></div></div><div><div></div></div><div><div></div></div><div><div></div></div>
    

Preparation code output

<div><div></div></div><div><div></div></div><div><div></div></div><div><div><div><div></div></div><div><div></div></div><div><div></div></div><div><div></div></div><div><div></div></div></div></div><div class="c" id="i"><div></div></div><div><div></div></div><div><div></div></div><div><div></div></div>

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
with class
document.querySelector(".c")
pending…
with id
document.querySelector("#i")
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