innerText vs innerHTML vs textContent vs setAttribute vs dataset

Benchmark created on


Setup

const N = document.createElement( 'b' )

Test runner

Ready to run.

Testing in
TestOps/sec
innerText
N.innerText = Math.random()
ready
innerHTML
N.innerHTML = Math.random()
ready
textContent
N.textContent = Math.random()
ready
setAttribute
N.setAttribute( `A`, Math.random() )
ready
dataset
N.dataset.A = Math.random()
ready

Revisions

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