jQuery .css("height") vs .height() (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 class="test"><h1>abcabcabc</h1></div>

Setup

var h = 0;
    var item=$("div.test");

Test runner

Ready to run.

Testing in
TestOps/sec
.css("height")
item.css("height", "100px");
ready
.height()
item.height("100px");
 
ready
style.height
item[0].style.height = '100px';
ready
.css({height})
item.css({"height": "100px"});
ready
Get .height()
h = item.height();
 
ready
Get style.height
h = item[0].style.height;
 
ready
Get .css()
h = item.css("height");
ready

Revisions

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