Id vs Class Whitelisting
JavaScript performance comparison
Preparation code
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div class="ignore extra1 extra2" id="ignore1"></div>
<script>
Benchmark.prototype.setup = function() {
var e = document.getElementById("ignore1");
var w10 = [];
for (var I = 10; I >= 1; I --) w10.push("ignore" + I);
};
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
ClassName IndexOf |
|
pending… |
ClassList Scan |
|
pending… |
Id WhiteList (1) |
|
pending… |
Id WhiteList (5) |
|
pending… |
Id WhiteList (10) |
|
pending… |
Id WhiteList (50) |
|
pending… |
ClassList Contains |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments