jQuery .data() performance vs .prop() performance (v45)

Revision 45 of this benchmark created by Jerome on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<input type="text" id="theInput" value="foo" cb="data1"></input>
<script>
  var theInput = $('#theInput');
  theInput.prop('someAttr', 'theValue').data('someData', 'theValue');
</script>

Setup

var $inp=$('input#theInput');
    var $dinp = $inp.get(0);
    var dinp=document.getElementById('theInput');

Test runner

Ready to run.

Testing in
TestOps/sec
via jquery - get
$inp.attr('cd');
ready
dom el - get
$dinp.getAttribute('cb');
ready
domel - get using jquery
dinp.getAttribute('cb');
ready
attribute - native
$dinp.cb;
ready

Revisions

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