Test name | Executions per second |
---|---|
innerHTML | 61.5 Ops/sec |
insertAdjacentHTML | 22872.0 Ops/sec |
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 );
document.getElementById( 'target' ).innerHTML += `
<div>
<span>Child 4</span>
</div>
`;
document.getElementById( 'target' ).insertAdjacentHTML( 'beforeend', `
<div>
<span>Child 4</span>
</div>
` );