jQuery vs. plain javascript (v3)

Revision 3 of this benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<input id="test" />
<script>
var
    prepared = document.getElementById("test")
  , $prepared = $("#test")  // How it is actually done in properly written jQuery applications
 ;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
getElementById("test")
document.getElementById("test").value = "foo";
ready
jQuery("#test")
$("#test").val("foo");
ready
getElementById but returning $
$(document.getElementById("test")).val("foo");
ready
Element.value from $ object
$("#test")[0].value = "foo";
ready
Prepared getElementById
prepared.value = "foo";
ready
Prepared jQuery("#test")
$prepared.val("foo");
ready
El.value from prepared $
$prepared[0].value = "foo";
ready

Revisions

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