Test name | Executions per second |
---|---|
getComputedStyle | 34.0 Ops/sec |
getBoundingClientRect | 48.9 Ops/sec |
clientHeight | 84.2 Ops/sec |
<div id="foo"></div>
var i = 5000;
while (i--) {
checkDisplay('foo');
}
function checkDisplay(id) {
return window.getComputedStyle(document.getElementById(id), null).getPropertyValue("height").slice(0, -2);
}
var i = 5000;
while (i--) {
checkDisplay('foo');
}
function checkDisplay(id) {
return document.getElementById(id).getBoundingClientRect().height;
}
var i = 5000;
while (i--) {
checkDisplay('foo');
}
function checkDisplay(id) {
return document.getElementById(id).clientHeight;
}