Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
getComputedStyle vs style.getPropertyValue vs. getBoundingClientRect
(version: 0)
Comparing performance of:
style.getPropertyValue vs getBoundingClientRect vs getComputedStyle
Created:
one year ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<div id="foo">some content <div>text</div> yet one more</div>
Tests:
style.getPropertyValue
var i = 5000; var elm = document.getElementById('foo'); while (i--) { checkDisplay(elm); } function checkDisplay(elm) { return parseInt(elm.style.getPropertyValue('width'), 10) === 0; }
getBoundingClientRect
var i = 5000; var elm = document.getElementById('foo'); while (i--) { checkDisplay(elm); } function checkDisplay(elm) { return Math.floor(elm.getBoundingClientRect().width) === 0; }
getComputedStyle
var i = 5000; var elm = document.getElementById('foo'); while (i--) { checkDisplay(elm); } function checkDisplay(elm) { return parseInt(window.getComputedStyle(elm, null).getPropertyValue('width'), 10) === 0; }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
style.getPropertyValue
getBoundingClientRect
getComputedStyle
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0.1 Safari/605.1.15
Browser/OS:
Safari 18 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
style.getPropertyValue
1652.9 Ops/sec
getBoundingClientRect
713.6 Ops/sec
getComputedStyle
441.6 Ops/sec
Related benchmarks:
window.getComputedStyle vs. className
window.getComputedStyle vs. getBoundingClientRect
window.style vs. getBoundingClientRect
window.getComputedStyle vs. getBoundingClientRect vs. window.getComputedStyle without getters
window.getComputedStyle vs. getBoundingClientRect width calculation
window.getComputedStyle vs. getBoundingClientRect 1111
style.getPropertyValue vs. getBoundingClientRect
Comments
Confirm delete:
Do you really want to delete benchmark?