Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Imperative DOM vs innerHTML vs <template>
How do imperative DOM manipulation, innerHTML, and template stamping compare on speed?
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36
Browser:
Chrome 129
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
innerHTML
83.1 Ops/sec
Imperative DOM
221364.9 Ops/sec
<template>
152713.6 Ops/sec
HTML Preparation code:
<template id="template"> <div> <p class="font-bold">Hello!</p> </div> </template> <output id="output"></output>
Script Preparation code:
output.replaceChildren();
Tests:
innerHTML
output.innerHTML += ` <div> <p class="font-bold">Hello!</p> </div>`;
Imperative DOM
const div = document.createElement('div'); const p = document.createElement('p'); p.classList.add('font-bold'); p.textContent = 'Hello!'; div.appendChild(p); output.appendChild(div);
<template>
output.appendChild(template.content.cloneNode(true));