replaceWith vs replaceChild

Benchmark created on


Setup

const a = document.createElement('div')
a.append('')

Test runner

Ready to run.

Testing in
TestOps/sec
replaceWith
const b = a.childNodes[0]
b.replaceWith('')
ready
replaceChild
const b = a.childNodes[0]
a.replaceChild(document.createTextNode(''), b)
ready

Revisions

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