Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36
Chrome 97
Mac OS X 10.15.7
Desktop
3 years ago
Test name Executions per second
innerHTML 214.2 Ops/sec
insertAdjacentHTML 260722.2 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>
    ` );