jQuery CSS vs Width vs Native Width (v9)

Revision 9 of this benchmark created on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<div id="target">
</div>

Setup

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

Test runner

Ready to run.

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

Revisions

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