Test name | Executions per second |
---|---|
Remove firstChild | 3185179.8 Ops/sec |
RemoveChildren | 2367089.0 Ops/sec |
<div id='messages'></div>
let list = document.getElementById("messages");
for(i=0; i<1000; i++) {
list.innerHTML += "<span>Text</span>"
}
let list = document.getElementById("messages");
while (list.firstChild) {
list.removeChild(list.firstChild);
}
let list = document.getElementById("messages");
list.replaceChildren();