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
Tests whether closest or parent while loops are faster.
<block><block><block><block><block>
<div inert><div><div><div><div>
<img/>
</div></div></div></div></div>
</block></block></block></block></block>
const img = document.querySelector('img');
const div = document.querySelector('div[inert]');
function hasInert(el, parent) {
let node = el;
while (node && node !== parent) {
if (node.hasAttribute('inert')) return true;
node = node.parentElement;
}
return false;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Using closest |
| ready |
Using while loop |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.