jQuery .attr() performance vs .css() (v84)

Revision 84 of this benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<input type="text" id="theInput" value="foo" style="background-color:red; border:1px solid yellow"></input>
<script>
  var dom= document.getElementById("theInput");
  var $dom= $(dom);
  $dom.css('min-height', '30').attr('min-height', '30');
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
css set
$dom.css('height','30');
ready
attr set
$dom.attr('height','30');
ready
.height() set
$dom.height('30');
ready
.height() get
$dom.height();
ready
css get
$dom.css('height');
ready
attr get
$dom.attr('height');
ready

Revisions

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