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 to see what speeds the browser DOM runs at in various browsers.
DOM Core Performance: Appending, Prepending, InnerHTML, Buffered InnerHTML
<div id="-test-div" style="background-color: grey; position: absolute; z-index: 1;"></div>
<script>
var div = document.getElementById('-test-div');
function testAppend(div) {
var add = null;
for (var i = 0; i <= 1000; i++) {
add = document.createElement('div');
add.className = 'browser_dom_test';
add.innerHTML = '<p>Some inner content.</p>';
div.appendChild(add);
}
}
function testPrepend(div) {
var add = null;
for (var i = 0; i <= 1000; i++) {
add = document.createElement('div');
add.className = 'browser_dom_test';
add.innerHTML = '<p>Some inner content.</p>';
div.insertBefore(add, div.firstChild);
}
}
function testInnerHTML(div) {
var add = null;
for (var i = 0; i <= 1000; i++) {
add = ['<div class="browser_dom_test">'];
add.push('<p>Some inner content.</p>');
add.push('</div>');
div.innerHTML = add.join('');
}
}
function testBufferInnerHTML(div) {
var add=[];
for (var i = 0; i <= 1000; i++) {
add.push('<div class="browser_dom_test">');
add.push('<p>Some inner content.</p>');
add.push('</div>');
}
div.innerHTML = add.join('');
}
</script>
// Remove all insertions.
div.innerHTML = "";
Ready to run.
Test | Ops/sec | |
---|---|---|
Append |
| ready |
Prepend |
| ready |
innerHTML |
| ready |
innerHTML + buffer |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.