jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
Added a .className reset to each test so that we're actually testing the addition of the classes.
Also cached the DOM selection/jQuery object creation to reduce the test down to what is actually being tested.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
</script>
<script src="http://zeptojs.com/zepto.min.js"></script>
<div id="testDiv"></div>
<style>
.class1{ color: red }
</style>
<script>
var $z = Zepto;
var $ = jQuery;
var elem = document.getElementById("testDiv");
var jqElem = $(elem);
var zElem = $z(elem);
var supportClassList = !!elem.classList;
function addClassF(el,cls){
var clss;
if (typeof cls === "string" ) {
clss = cls.split(" ");
}
else /*if ( cls instanceof Array )*/ {
clss = cls;
}
var i, len = clss.length;
for(i = 0; i < len ; i+=1 ) el.classList.add(clss[i]);
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
jquery addClass |
| ready |
DOM classList |
| ready |
Zepto addClass |
| ready |
DOM classList with wrapper |
| ready |
native |
| ready |
DOM classList variadic (newest impls) |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.