Test name | Executions per second |
---|---|
innerHTML | 8930150.0 Ops/sec |
removeChild | 10675917.0 Ops/sec |
remove | 10654275.0 Ops/sec |
innerText | 7672295.5 Ops/sec |
textContent | 8612134.0 Ops/sec |
<div id="container"></div>
var node = document.getElementById('container');
for(var i = 0; i < 1000; i++) node.appendChild(document.createElement('div'));
var node = document.getElementById('container');
node.innerHTML = '';
var node = document.getElementById('container');
while(node.firstChild) node.removeChild(node.firstChild)
var node = document.getElementById('container');
while(node.firstChild) node.firstChild.remove()
var node = document.getElementById('container');
node.innerText = '';
var node = document.getElementById('container');
node.textContent = '';