Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0
Chrome 134
Windows
Desktop
11 days ago
Test name Executions per second
cloneNode(true) 131.6 Ops/sec
innerHTML 99.1 Ops/sec
Script Preparation code:
x
 
var str = `<div>${Math.random().toString().slice(2)}</div>`;
var temp = document.createElement('template')
var res = '';
for(i=0; i<30000; i++){
    res += str
}
temp.innerHTML = res;
var div = document.createElement('div')
Tests:
  • cloneNode(true)

     
    div.append(temp.content.cloneNode(true)); 
  • innerHTML

     
    div.innerHTML = res;