Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
createElement vs template clone (prefound template)
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/127.0.0.0 Safari/537.36
Browser:
Chrome 127
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
createElement
1037565.1 Ops/sec
template
965551.4 Ops/sec
HTML Preparation code:
<body> <template id="option-template"> <option>Sample Option</option> </template> </body>
Script Preparation code:
window.template = document.getElementById('option-template');
Tests:
createElement
const option = document.createElement('option'); option.id = `option-${i}`; option.setAttribute('data-foo', 'bar'); option.selected = true; option.textContent = 'aaaa';
template
const clonedOption = template.content.firstElementChild.cloneNode(true); clonedOption.id = `option-${i}`; clonedOption.setAttribute('data-foo', 'bar'); clonedOption.selected = true; clonedOption.textContent = 'aaaa';