Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
cached window.getComputedStyle vs. getBoundingClientRect vs clientHeight
(version: 1)
Comparing performance of:
getComputedStyle vs getBoundingClientRect vs clientheight
Created:
8 months ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<div id="foo"></div>
Tests:
getComputedStyle
var i = 5000; var computedStyle; while (i--) { checkDisplay('foo'); } function checkDisplay(id) { computedStyle = computedStyle || window.getComputedStyle(document.getElementById(id), null); return computedStyle.getPropertyValue("display") === "none"; }
getBoundingClientRect
var i = 5000; while (i--) { checkDisplay('foo'); } function checkDisplay(id) { return document.getElementById(id).getBoundingClientRect().width === 0; }
clientheight
var i = 5000; while (i--) { checkDisplay('foo'); } function checkDisplay(id) { return document.getElementById(id).clientHeight === 0; }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
getComputedStyle
getBoundingClientRect
clientheight
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
18 days ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:151.0) Gecko/20100101 Firefox/151.0
Browser/OS:
Firefox 151 on Mac OS X 10.15
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
getComputedStyle
1044.4 Ops/sec
getBoundingClientRect
397.9 Ops/sec
clientheight
716.4 Ops/sec
Related benchmarks:
window.getComputedStyle vs getAttribute
window.getComputedStyle vs. memoized version
window.getComputedStyle vs. getBoundingClientRect
window.getComputedStyle vs. getBoundingClientRect vs clientHeight
window.getComputedStyle vs. getBoundingClientRect vs. window.getComputedStyle without getters
clientHeight + clientWidth vs getComutedStyle()
window.getComputedStyle vs. getBoundingClientRect width calculation
window.getComputedStyle vs. getBoundingClientRect 1111
window.getComputedStyle vs. getBoundingClientRect get width
Comments
Confirm delete:
Do you really want to delete benchmark?