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

Revision 47 of this benchmark created on


Preparation HTML

<script src="https://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('min-height','30');
ready
attr set
$dom.attr('min-height','30');
ready
css get
$dom.css('min-height');
ready
attr get
$dom.attr('min-height');
ready

Revisions

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