Text.data vs. Element.textContent - short strings

Benchmark created on


Preparation HTML

<p></p>

Setup

let element = document.querySelector("body p");
let text = document.createTextNode("");
element.append(text);

Test runner

Ready to run.

Testing in
TestOps/sec
Text Node data property - short string
text.data = (Math.random() * 10 | 0).toString();
ready
Element textContent property - short string
element.textContent = (Math.random() * 10 | 0).toString();
ready

Revisions

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