Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
ResizeObserver vs matchMedia 3x
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:115.0) Gecko/20100101 Goanna/6.7 Firefox/115.0 PaleMoon/33.7.1
Browser:
Pale Moon (Firefox Variant) 33
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
ResizeObserver
99.7 Ops/sec
matchMedia
105.1 Ops/sec
HTML Preparation code:
<div> Hello </div>
Tests:
ResizeObserver
let value; const observer = new ResizeObserver(entries => { value = entries[0].contentRect.width; }) observer.observe(document.body) for (let i = 300; i <= 2000; i++) { window.resizeTo(i, 1000) } for (let i = 300; i <= 2000; i++) { window.resizeTo(i, 1000) } for (let i = 300; i <= 2000; i++) { window.resizeTo(i, 1000) }
matchMedia
let value; const handleMatchChange = (val) => { value = val; } const match1 = window.matchMedia('screen and (min-width: 800px)') match1.addEventListener('change', handleMatchChange); const match2 = window.matchMedia('screen and (min-width: 480px)') match2.addEventListener('change', handleMatchChange); const match3 = window.matchMedia('screen and (min-width: 1200px)') match3.addEventListener('change', handleMatchChange); for (let i = 500; i <= 1920; i++) { window.resizeTo(i, 1000) } for (let i = 300; i <= 2000; i++) { window.resizeTo(i, 1000) } for (let i = 300; i <= 2000; i++) { window.resizeTo(i, 1000) }