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
Test which method is fastest to append multiple elements to DOM ~~~ simple JavaScript - without any library
<div id="content">
<div>
1
</div>
<div>
2
</div>
<div>
3
</div>
<div>
4
</div>
<div>
5
</div>
<div>
6
</div>
<div>
7
</div>
<div>
8
</div>
<div>
9
</div>
<div>
10
</div>
</div>
<div id="target">
</div>
content = document.getElementById('content');
target = document.getElementById('target');
function testInnerHtml() {
target.innerHTML = content.innerHTML;
}
function testAppendChild() {
var appendChild = content.cloneNode(true),
n;
while (n = appendChild.firstChild) {
target.appendChild(n);
}
}
function testDocumentFragment() {
var df = document.createDocumentFragment(),
df_nodes = content.cloneNode(true),
n;
while (n = df_nodes.firstChild) {
df.appendChild(n);
}
target.appendChild(df);
}
document.getElementById('target').innerHTML = "";
Ready to run.
Test | Ops/sec | |
---|---|---|
innerHTML |
| ready |
appendChild |
| ready |
documentFragment |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.