Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
createContextualFragment vs insertAdjacentHTML long HTML strings repeat 10
(version: 1)
createContextualFragment vs insertAdjacentHTML: Incrementally append long HTML strings.
Comparing performance of:
insertAdjacentHTML vs createContextualFragment
Created:
one year ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<div id='id'></div>
Script Preparation code:
// Change these numbers to see how well they scale batch = 1000; repeat = 10;
Tests:
insertAdjacentHTML
const box = document.getElementsByTagName("div").item(0); let html = ''; for (let i = 0; i < batch; i++) html += '<div class="a b"><div>Test</div></div>'; for (let i = 0; i < repeat; i++) box.insertAdjacentHTML('beforeend', html);
createContextualFragment
const box = document.getElementsByTagName("div").item(0); let html = ''; for (let i = 0; i < batch; i++) html += '<div class="a b"><div>Test</div></div>'; for (let i = 0; i < repeat; i++) { const range = document.createRange(); range.selectNode(box); const documentFragment = range.createContextualFragment(html); box.appendChild(documentFragment); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
insertAdjacentHTML
createContextualFragment
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:138.0) Gecko/20100101 Firefox/138.0
Browser/OS:
Firefox 138 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
insertAdjacentHTML
36.2 Ops/sec
createContextualFragment
29.2 Ops/sec
Related benchmarks:
append vs appendChild vs insertAdjacentHTML vs DOMParser vs createContextualFragment vs append documentFragment
textContent vs insertAdjacentText 500x
insertAdjacentHTML vs insertBefore
insertAdjacentHTML VS append VS appendChild (createDocumentFragment)
insertAdjacentHTML VS append VS appendChild (createDocumentFragment) [MINIMAL]
innerHTML vs insertAdjacentHTML vs appendChild vs append vs insertAdjacentElement
insertAdjacentHtml(loop) vs innerHTML(once)
insertAdjacentHTML vs appendChild vs append vs insertAdjacentElement vs innerHTML repeat 1000
innerHTML vs insertAdjacentHTML vs createContextualFragment long HTML strings repeat 10
Comments
Confirm delete:
Do you really want to delete benchmark?