Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
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/134.0.0.0 Safari/537.36
Browser:
Chrome 134
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Benchmark engine:
Benchmark.js
Imperative DOM
841K/s
<template>
589K/s
innerHTML
189/s
View exact numbers
Test name
Executions per second
✓
Imperative DOM
841,379 Ops/sec
<template>
588,531 Ops/sec
innerHTML
189 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));