Run details:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Mobile Safari/537.36
Chrome Mobile 117
Android
Mobile
one year ago
Test name Executions per second
innerHTML 104.5 Ops/sec
insertAdjacentHTML 75466.6 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>
    ` );