$().prop vs $().prop vs $().data vs $().val (v72)

Revision 72 of this benchmark created by Heavensrevenge on


Preparation HTML

<script src="//code.jquery.com/jquery-git2.js"></script>

<input id="el" value="stuff" data-value="stuff" />

Setup

var i = 0,
          el = document.getElementById('el'),
          $el = $(el);

Test runner

Ready to run.

Testing in
TestOps/sec
$.fn.val get
$el.val();
ready
$.fn.prop get
$el.prop('value');
ready
$.fn.attr get
$el.attr('value');
ready
JS get property
el.value
ready
JS getAttribute
el.getAttribute('value');
ready
JQ[0] to Js getAttribute
$el[0].getAttribute('value');
ready
JQ[0] to Js
$el[0].value;
ready
$.prop get
$.prop($el[0], 'value');
ready
$.fn.data get
$el.data('value')
ready
$.data get
$.data($el[0], 'value')
ready

Revisions

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