Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
iframe traversal getElementsByTagName vs querySelectorAll w\ shadowroot traversal
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/26.5 Safari/605.1.15
Browser:
Safari 26
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one month ago
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
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; } }