Test name | Executions per second |
---|---|
getComputedStyle | 166.9 Ops/sec |
getBoundingClientRect | 319.9 Ops/sec |
<div id="foo">test</div>
const elem = document.getElementById("foo");
var i = 5000;
while (i--) {
getHeight();
}
function getHeight() {
return parseFloat(getComputedStyle(elem).height);
}
const elem = document.getElementById("foo");
var i = 5000;
while (i--) {
getHeight();
}
function getHeight() {
return elem.getBoundingClientRect().height;
}