jQuery.val vs element.value (v3)

Revision 3 of this benchmark created on


Description

Testing the performance of assignment through $.val() and element.value

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<input id="foo" type="hidden">

Setup

var value = Math.random();
    var $el = $('#foo');
    var el = document.getElementById('foo');

Test runner

Ready to run.

Testing in
TestOps/sec
$.val()
$('#foo').val(value);
ready
$.value
$('#foo').value = value;
ready
$el.value
$el[0].value = value;
ready
Native.value
document.getElementById('foo').value = value;
ready
el.value
el.value = value;
ready

Revisions

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