Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
iframe traversal getElementsByTagName vs querySelectorAll w\ shadowroot traversal
(version: 1)
Comparing performance of:
finding a window in live collection vs finding a window with shadowroot handling
Created:
one month ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<div> </div> <div> <iframe src="about: blank"></iframe> </div> <div> <iframe src="about: blank"></iframe> </div> <div> <template shadowrootmode="open"> <style> body { background-color: blue; } </style> <iframe src="about: blank"></iframe> </template> </div>
Script Preparation code:
var iframeElementCollection = document.getElementsByTagName('iframe'); var findWindow = window.frames[0]; function isIframeElement(el) { return el.tagName === 'IFRAME'; } function getAllIframes(from) { const iframes = []; for(const el of from.querySelectorAll('*')) { if(isIframeElement(el)) { iframes.push(el); } else if(el.shadowRoot) { iframes.push(...getAllIframes(el.shadowRoot)); } } return iframes; }
Tests:
finding a window in live collection
for(const iframeEl of iframeElementCollection) { if(findWindow === iframeEl.contentWindow) { return iframeEl; } }
finding a window with shadowroot handling
for(const iframeEl of getAllIframes(document.body)) { if(findWindow === iframeEl.contentWindow) { return iframeEl; } }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
finding a window in live collection
finding a window with shadowroot handling
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one month ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.5 Safari/605.1.15
Browser/OS:
Safari 26 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
finding a window in live collection
17211382.0 Ops/sec
finding a window with shadowroot handling
409289.0 Ops/sec
Related benchmarks:
QuerySelector vs Get First Element By Tag Name
querySelectorAll vs getElementsByTagName 2
querySelector vs getElementsByTagName check presence
querySelectorAll() vs getElementsByTagName() - with constant
querySelector vs getElementsByTagName simple select
Mapping a pair of numbers (2 numbers) to another number [Algorithm 1]
querySelectorAll vs getElementsByTagName iteration v2
querySelector() vs getElementsByTagName()[0]
querySelector() vs getElementsByTagName()[0] prerun
Comments
Confirm delete:
Do you really want to delete benchmark?