:not or not :not

JavaScript performance comparison

Test case created by mekwall

Preparation code

<div id="container" class="bar"></div>
<script>
Benchmark.prototype.setup = function() {
    var container = document.getElementById("container");
    for (var i = 0; i < 1000; i++) {
        container.appendChild(document.createElement("div"));
    }
};

Benchmark.prototype.teardown = function() {
    var container = document.getElementById("container");
    while (container.firstChild) {
        container.removeChild(container.firstChild);
    }
};
</script>

Preparation code output

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Using :not
var el = document.querySelectorAll("#container:not(.foo) div");
pending…
Not using :not
var el = document.querySelectorAll("#container.bar 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

Add a comment