innerHTML vs createTextNode (1 link) (v9)

Revision 9 of this benchmark created on


Setup

window.num = 1;

Test runner

Ready to run.

Testing in
TestOps/sec
innerHTML (1 link)
window.num++;
const root = document.createElement('div');
root.innerHTML = `text with a <a href="https://example.com/">link${window.num}</a>`;
root.querySelector("a");
ready
createTextNode (1 link)
window.num++;
const root = document.createElement('div');
root.appendChild(document.createTextNode(`text with a `));
const anchor = document.createElement('a');
anchor.setAttribute("href", "https://example.com/");
anchor.appendChild(document.createTextNode(`link${window.num}`));
root.appendChild(anchor);
root.querySelector("a");
ready

Revisions

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