getBoundingClientRect vs. offsetWidth/offsetHeight (v12)

Revision 12 of this benchmark created on


Preparation HTML

<div id="foo" style="width:500px; height:500px; padding:10px; border:10px solid #000000;">
</div>

Setup

Benchmark.prototype.setup = function() {
      var foo = document.getElementById('foo');
    };

Test runner

Ready to run.

Testing in
TestOps/sec
getBoundingClientRect
var boundingClientRect = foo.getBoundingClientRect();
ready
offsetWidth/offsetHeight
var width = foo.offsetWidth;
var height = foo.offsetHeight;
var top = foo.scrollTop;
var bottom = foo.scrollBottom;
var left = foo.scrollLeft;
var right = foo.scrollRight;
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.