Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Safari/605.1.15
Safari 15
Mac OS X 10.15.7
Desktop
2 years ago
Test name Executions per second
innerHTML 137.6 Ops/sec
insertAdjacentHTML 164207.4 Ops/sec
Script Preparation code:
x
 
const targetElem = document.createElement( 'DIV' );
targetElem.id = 'target';
targetElem.innerHTML = `
    <div>
        <span>Child 1</span>
    </div>
    <div>
        <span>Child 2</span>
    </div>
    <div>
        <span>Child 3</span>
    </div>
`;
document.body.appendChild( targetElem );
Tests:
  • innerHTML

     
    document.getElementById( 'target' ).innerHTML += `
        <div>
            <span>Child 4</span>
        </div>
    `;
  • insertAdjacentHTML

     
    document.getElementById( 'target' ).insertAdjacentHTML( 'beforeend', `
        <div>
            <span>Child 4</span>
        </div>
    ` );