jQuery CSS vs Width vs Native Width (v5)

Revision 5 of this benchmark created on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<div id="target" style="width:100px;height:100px; background:#faa">
</div>

Setup

var $target = $("#target");
  var target = document.getElementById("target");

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery CSS function
$target.css("width");
ready
jQuery Width function
$target.width();
ready
jquery inline styling
$target[0].style.width;
ready
native inline styling
target.style.width
ready
Native offsetWidth (IE8+)
target.offsetWidth
ready
jQuery innerWidth function
$target.innerWidth();
ready
jQuery outerWidth function
$target.outerWidth();
ready
jQuery outerWidth(true) function
$target.outerWidth(true);
ready
Native clientWidth
target.clientWidth;
ready

Revisions

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