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
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div id="parent">
<p class="active info">text</p>
<p class="active warning">text</p>
</div>
<div id="parent2">
<p class="info">text</p>
<p class="warning">text</p>
</div>
var removeClass = function(array, className) {
var i = 0,
len = array.length;
for (; i < len; i++) {
if (array[i].classList) {
array[i].classList.remove(className);
} else {
var names = array[i].className.split(' '),
j = 0,
sublen = names.length;
for (; j < sublen; j++) {
if (names[j] === className) {
names[j] = "";
}
}
array[i].className = names.join('');
}
}
};
var addClass = function(array, className) {
var i = 0,
len = array.length;
for (; i < len; i++) {
if (array[i].classList) {
if (array[i].classList.contains(className)) {
array[i].classList.add(className);
}
} else {
var names = array[i].className.split(' '),
j = 0,
sublen = names.length;
for (; j < sublen; j++) {
if (names[j] === className) {
names[j] = "";
}
}
names.push(' ');
names.push(className);
array[i].className = names.join('');
}
}
};
var parent2 = document.getElementById('parent2');
Ready to run.
Test | Ops/sec | |
---|---|---|
query selector |
| ready |
jQuery |
| ready |
Add class queryselector |
| ready |
jquery addclass |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.