Test name | Executions per second |
---|---|
appendChild fragment | 9502907.0 Ops/sec |
appendChildren | 3244.1 Ops/sec |
<div id="container"></div>
var container = document.getElementById('container');
var fragment = document.createDocumentFragment();
for (let i = 0; i < 1000; i++) {
const li = document.createElement('li');
li.textContent = `Item ${i}`;
fragment.appendChild(li);
}
var elements = [];
for (let i = 0; i < 1000; i++) {
const li = document.createElement('li');
li.textContent = `Item ${i}`;
elements.push(li)
}
container.appendChild(fragment)
container.append(elements)