replaceWith vs replaceChild (v2)

Revision 2 of this 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
replaceWith node
const b = a.childNodes[0]
b.replaceWith(document.createTextNode(''))
ready

Revisions

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