jQuery .prop() performance vs .attr() performance (v70)

Revision 70 of this benchmark created on


Preparation HTML

<script src="//code.jquery.com/jquery-2.0.3.min.js"></script>
<input type="text" id="theInput" value="foo"></input>
<script>
  var theInput$ = $('#theInput');
  var theInput = document.getElementById('theInput');
  theInput$.attr('someAttr', 'theValue').prop('someProp', 'theValue');
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Attribute get
theInput$.attr('someAttr');
ready
Attribute set
theInput$.attr('someAttr', 'newValue');
ready
.val() get
theInput$.val();
ready
.val() set
theInput$.val('newValue');
ready
Prop get
theInput$.prop('someProp');
ready
Prop Set
theInput$.prop('someProp', 'newValue');
ready
Dom getAttribute
theInput.getAttribute('someAttr');
ready
Dom setAttribute
theInput.setAttribute('someAttr', 'newValue');
ready
jq-Mix getAttribute
theInput$[0].getAttribute('someAttr');
ready
jq-Mix setAttribute
theInput$[0].setAttribute('someAttr', 'newValue');
ready

Revisions

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