Edit text by "textContent" vs "innerText" vs "innerHTML"

Benchmark created on


Description

Test the difference in javascript performance when edit text by "textContent" versus edit text by "innerText" versus edit text by "innerHTML"

Preparation HTML

<div id="edit-text">Text to edit</div>

Setup

const editText = document.getElementById("edit-text")

Test runner

Ready to run.

Testing in
TestOps/sec
Edit text by "textContent"
editText.textContent = "Text edited"
ready
Edit text by "innerText"
editText.innerText = "Text edited"
ready
Edit text by "innerHTML"
editText.innerHTML = "Text edited"
ready

Revisions

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