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
what method for empty a element is faster ?
<div id="container"></div>
<style type="text/css">
#box, #box * {
font-size: 0;
}
#box * {
display: inline-block;
width: 1px;
height: 1px;
padding: 0;
margin: 0;
background-color: blue;
}
</style>
var box = document.createElement('div');
box.id = 'box';
document.getElementById('container').appendChild(box);
var CHILDREN = 10000;
function refill() {
for (var i = box.childNodes.length; i < CHILDREN; i++)
box.appendChild(document.createElement('div'));
}
document.getElementById('container').removeChild(box);
Ready to run.
Test | Ops/sec | |
---|---|---|
remove first child |
| ready |
remove last child |
| ready |
innerHTML |
| ready |
textContent |
| ready |
hasChildNodes |
| ready |
check first child |
| ready |
remove by reference foreach |
| ready |
remove by reference loop |
| ready |
shallow clone |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.