BSI vs Mootools add/remove class

JavaScript performance comparison

Revision 3 of this test case created

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/mootools/1.3/mootools-yui-compressed.js">
</script>
<script src="http://bytes1.dyndns.org/BSI/website-app.js"></script>
<div id="foo" class="bar">
</div>

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
Mootolls add/removeClass()
var foo = $("foo");
foo.addClass("foo");
foo.removeClass("foo");
 
pending…
vanilla JS
var foo = document.getElementById("foo");
var original = foo.className;

foo.className = foo.className + " foo";

foo.className = original;
pending…
vanilla replace()
var foo = document.getElementById("foo");

foo.className = foo.className += " foo";

foo.className = foo.className.replace(/\bfoo\b/, '');
 
pending…
BSI
var foo = BSI.id("foo");
foo.addClass("foo");
foo.removeClass("foo");
pending…
BSI chained
BSI.id("foo").addClass("foo").removeClass("foo");
pending…
vanilla proper
var foo = document.getElementById("foo");

foo.classList.add("foo");
foo.classList.remove("foo");
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. Here’s a list of current revisions for this page:

0 comments

Add a comment