Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
insertAdjacentHTML+innerText vs escape+insertAdjacentHTML
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:143.0) Gecko/20100101 Firefox/143.0
Browser:
Firefox 143
Operating system:
Windows
Device Platform:
Desktop
Date tested:
7 months ago
Test name
Executions per second
insertAdjacentHTML+innerText
239.3 Ops/sec
escape+insertAdjacentHTML
649.6 Ops/sec
insertAdjacentHTML+innerText w/ lastElementChild
226.7 Ops/sec
HTML Preparation code:
<div id='dest'></div>
Script Preparation code:
const dest = document.getElementById('dest'); function escapeHtml(unsafe) { return unsafe .replace(/&/g, "&") .replace(/</g, "<") .replace(/>/g, ">"); }
Tests:
insertAdjacentHTML+innerText
for(var i=0; i<1000; ++i){ dest.insertAdjacentHTML("beforeend", "<p></p>"); dest.lastChild.innerText = `Hello ${i} & hello again.`; }
escape+insertAdjacentHTML
var html = ""; for(var i=0; i<1000; ++i){ html += `<p>${escapeHtml(`Hello ${i} & hello again.`)}</p>`; } dest.innerHTML = html;
insertAdjacentHTML+innerText w/ lastElementChild
for(var i=0; i<1000; ++i){ dest.insertAdjacentHTML("beforeend", "<p></p>"); dest.lastElementChild.innerText = `Hello ${i} & hello again.`; }