getBoundingClientRect vs offsetHeight (v3)

Revision 3 of this benchmark created by Pavel on


Preparation HTML

<div id="myDiv" style="width:300px; height: 200px; -webkit-transform:translate3d(0,0,0)"></div>

Setup

var myDiv = document.getElementById('myDiv');

Test runner

Ready to run.

Testing in
TestOps/sec
getBoundingClientRect
var rect = myDiv.getBoundingClientRect(),
height = rect.bottom - rect.top;
ready
offsetHeight
var height = myDiv.offsetHeight;
ready
clientHeight
var height = myDiv.clientHeight;
ready
var height = myDiv.getBoundingClientRect().height;
ready

Revisions

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

  • Revision 1: published by Oliver Fernandez on
  • Revision 2: published by Brian Jemilo II on
  • Revision 3: published by Pavel on