getComputedStyle vs style vs .css() (v9)

Revision 9 of this benchmark created on


Description

getComputedStyle vs style vs .css()

Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<div id="element" style="width:200px">
  My Element
</div>

Test runner

Ready to run.

Testing in
TestOps/sec
jq css {width}
var element = $("#element"),
    width2 = parseInt(element.css("width"), 10);
ready
js .width()
var element = $("#element"),
    width2 = element.width()
ready
style
var element = document.getElementById("element"),
    width1 = parseInt(element.style.width, 10);
ready

Revisions

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