Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:125.0) Gecko/20100101 Firefox/125.0
Firefox 125
Windows
Desktop
one year ago
Test name Executions per second
createElement 1247677.5 Ops/sec
createContextualFragment 382694.3 Ops/sec
HTML Preparation code:
AخA
 
1
<div></div>
Tests:
  • createElement

     
    const div = document.createElement('div')
    div.innerHTML = 'Hello';
    return div.outerHTML;
  • createContextualFragment

     
    const frag = document.createRange().createContextualFragment(`<div>Hello</div>`);
    const domNode = frag.firstElementChild;
    return domNode.outerHTML;