css selector

JavaScript performance comparison

Test case created by adventure

Preparation code

<script>
for (var i=0; i<10000; i++) {
    var div = document.createElement('div');
    div.className = 'outside-div';
    if (i === 5000) {
        var innerDiv = document.createElement('div');
        innerDiv.className = 'inner-div';
        div.appendChild(innerDiv);
    }
    document.body.appendChild(div);
}
</script>
    

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
selector by class
document.querySelector('div.outside-div > .inner-div');
pending…
selector by tag
document.querySelector('div.outside-div > div');
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