Test name | Executions per second |
---|---|
getComputedStyle | 20.5 Ops/sec |
getBoundingClientRect | 59.4 Ops/sec |
clientHeight | 102.9 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;
}