Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36
Chrome 97
Mac OS X 10.14.6
Desktop
3 years ago
Test name Executions per second
createContextualFragment 26.3 Ops/sec
innerHTML 31.8 Ops/sec
Script Preparation code:
AخA
 
var str = `<div>${Math.random().toString().slice(2)}</div>`;
var range = document.createRange();
var temp = document.createElement('template')
var res = '';
for(i=0; i<30000; i++){
    res += str
}
Tests:
  • createContextualFragment

     
    var test1 = range.createContextualFragment(res)
  • innerHTML

     
    temp.innerHTML = res
    var test2 = temp.content