Text.data vs. Element.textContent - long 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 data property - long string
text.data = (Math.random() * Number.MAX_SAFE_INTEGER).toString(2);
ready
Element textContent property - long string
element.textContent = (Math.random() * Number.MAX_SAFE_INTEGER).toString(2);
ready

Revisions

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