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
document.getElementsByClassName
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div class="testing"></div>
function removeAddClass(classToRemove, classToAdd){
var elems = document.getElementsByClassName(classToRemove);
var removedElements = [];
if (!elems) return;
for (var i=elems.length-1;i>=0;i--) {
var elem=elems[i];
var classes=elem.className.split(" ");
var newClass = classes.splice(classes.indexOf(classToRemove),1).join(" ");
elem.className=classes + " " + classToAdd;
}
}
Ready to run.
Test | Ops/sec | |
---|---|---|
CSS Selecter |
| ready |
JS Class |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.