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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Safari/605.1.15
Browser:
Safari 18
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
9 months ago
Test name
Executions per second
createElementNS
19.9 Ops/sec
cloneNode (shallow)
23.2 Ops/sec
cloneNode (deep)
22.3 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)) }