Native Dojo Class Manipulation v HTML5

JavaScript performance comparison

Revision 7 of this test case created by Darth

Preparation code

<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.8.1/dojo/dojo.js">
</script>
<div id="empty_class">
</div>
<div class="a_class" id="single_class">
</div>
<div class="a_class b_class c_class" id="many_classes">
</div>

<script>
require(['dojo/dom-class', 'dojo/dom'], function(dClass, dDom) {
  domClass = dClass;
  dom = dDom;
});
</script>
    

Preparation code output

<div id="empty_class"> </div> <div class="a_class" id="single_class"> </div> <div class="a_class b_class c_class" id="many_classes"> </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
Add Class - Dojo
domClass.add("single_class", "some_class");
pending…
Add Class - HTML5
document.getElementById("empty_class").classList.add("some_class");
pending…
Remove Class - Dojo
domClass.remove("single_class", "a_class");
pending…
Remove Class - HTML5
document.getElementById("single_class").classList.remove("a_class");
pending…
Toggle Class - Dojo
domClass.toggle("many_classes", "a_class");
pending…
Toggle Class - HTML5
document.getElementById("many_classes").classList.toggle("a_class");
pending…
Has Class - Dojo
domClass.contains("single_class", "a_class");
pending…
Has Class - HTML5
document.getElementById("single_class").classList.contains("a_class");
pending…
classList add with dojo byId
dom.byId("empty_class").classList.add("some_class");
pending…
classList remove with dojo byId
dom.byId("single_class").classList.remove("a_class");
pending…
classList toggle with dojo byId
dom.byId("many_classes").classList.toggle("a_class");
pending…
classList contains with dojo byId
dom.byId("single_class").classList.contains("a_class");
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