Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:105.0) Gecko/20100101 Firefox/105.0
Firefox 105
Windows
Desktop
2 years ago
Test name Executions per second
getComputedStyle 193.8 Ops/sec
getBoundingClientRect 360.3 Ops/sec
HTML Preparation code:
AخA
 
1
<div id="foo"></div>
Tests:
  • getComputedStyle

    x
     
    var i = 5000;
    const node = document.getElementById('foo')
    while (i--) {
        checkDisplay('foo');
    }
    function checkDisplay(id) {
        return parseFloat(window.getComputedStyle(node).height) > 0;
    }
  • getBoundingClientRect

     
    var i = 5000;
    const node = document.getElementById('foo')
    while (i--) {
        checkDisplay('foo');
    }
    function checkDisplay(id) {
        return node.getBoundingClientRect().height > 0;
    }