Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
SVG parsing 999
fastest way to inject svg in HTML code
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36
Browser:
Chrome 123
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
innerHTML
48.8 Ops/sec
DOMParser in loop
1.2 Ops/sec
HTML Preparation code:
<div id="target"></div>
Script Preparation code:
window.sampleSVG = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 58 58"><path fill="#26b99a" d="M29 58L3 45V13l26 13z"/><path fill="#556080" d="M29 58l26-13V13L29 26z"/><path fill="#434c6d" d="M3 13L28 0l27 13-26 13z"/></svg>' window.targetNode = document.getElementById("target")
Tests:
innerHTML
let i = 1000 let wrap = document.createElement("DIV"); do { wrap.innerHTML = window.sampleSVG; let el = wrap.firstChild; wrap.removeChild(el); window.targetNode.appendChild(el); window.targetNode.children; window.targetNode.firstChild.remove() } while(--i)
DOMParser in loop
let i = 1000 let parser = new DOMParser; do { let svgNode = parser.parseFromString(window.sampleSVG, "image/svg+xml").firstChild window.targetNode.appendChild(svgNode) window.targetNode.children; window.targetNode.firstChild.remove() } while(--i)