innerHTML vs replaceChildren

Benchmark created on


Preparation HTML

<div id="foo">Lorem ipsum <span id="bar">dolor</span></div>

Setup

const foo = document.getElementById('foo');

Test runner

Ready to run.

Testing in
TestOps/sec
innerHTML
foo.innerHTML = '';
ready
replaceChildren()
foo.replaceChildren();
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.