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:
7 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:
7 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36
Browser/OS:
Chrome 141 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
getComputedStyle
796.5 Ops/sec
getBoundingClientRect
148.1 Ops/sec
clientheight
238.6 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?