Querying Dom Elements

JavaScript performance comparison

Test case created by Todd Henderson

Preparation code

<div id='fixture'>Fixture Id</div>

<div class='fixtureClass'>Fixture Class</div>
    

Preparation code output

<div id='fixture'>Fixture Id</div> <div class='fixtureClass'>Fixture Class</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
document.getElementById
var div = document.getElementById('fixture');
pending…
document.getElementsByClassName
var div = document.getElementsByClassName('fixtureClass');
pending…
document.querySelector('#id')
var div = document.querySelector('#fixture');
pending…
document.querySelector('.class')
var div = document.querySelector('.fixtureClass');
pending…
document.querySelectorAll('#id')
var div = document.querySelectorAll('#fixture');
pending…
document.querySelectorAll('.class')
var div = document.querySelectorAll('.fixtureClass');
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.

0 Comments

Fixture Id
Fixture Class