Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
createElementNS vs cloneNode
Faster way to create new dom elements before insertion
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:
6 months ago
Test name
Executions per second
createElementNS
9.5 Ops/sec
cloneNode (shallow)
15.2 Ops/sec
cloneNode (deep)
15.4 Ops/sec
Tests:
createElementNS
const list = [] let n = 1e5 while (--n) { const c = document.createElementNS('http://www.w3.org/2000/svg', 'circle') c.setAttribute('cx', 39) c.setAttribute('cy', 0) c.setAttribute('r', 20) list.push(c) }
cloneNode (shallow)
const list = [] let n = 1e5 - 1 const c = document.createElementNS('http://www.w3.org/2000/svg', 'circle') c.setAttribute('cx', 39) c.setAttribute('cy', 0) c.setAttribute('r', 20) list.push(c) while (--n) { list.push(c.cloneNode(false)) }
cloneNode (deep)
const list = [] let n = 1e5 - 1 const c = document.createElementNS('http://www.w3.org/2000/svg', 'circle') c.setAttribute('cx', 39) c.setAttribute('cy', 0) c.setAttribute('r', 20) list.push(c) while (--n) { list.push(c.cloneNode(true)) }