Test performance of calling offsetwidth (v4)

Revision 4 of this benchmark created on


Preparation HTML

<div style="width:200px;height:200px">
<div id="e1" style="width:100%;"></div>
</div>
<script>
var e1 = document.getElementById("e1");
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Only offsetWidth
var width = e1.offsetWidth;
 
ready
Only computed width
var width = e1.clientWidth;
ready
offsetWidth and computed
var gCS = window.getComputedStyle(e1);
var width1 = gCS.width;
var width2 = e1.offsetWidth;
ready
offsetWidth after changing computed
var gCS = window.getComputedStyle(e1);
e1.style.width = gCS.width;
var width = e1.offsetWidth;
ready
style.width
var width = e1.style.width;
ready
2 times offsetWidth
var width1 = e1.offsetWidth;
var  width2 = e1.offsetWidth;
ready
parent width
var width = e1.offsetWidth;
var parentWidth = e1.parentNode.offsetWidth;
ready

Revisions

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