jQuery document on vs ready

JavaScript performance comparison

Revision 2 of this test case created

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
 

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
on()
$(document).on('ready',function() {
jQuery.noop();
});
pending…
ready
$(document).ready(function() {
jQuery.noop();
});
pending…
on(), document in context
$(window).on('ready',document,function() {
jQuery.noop();
});
pending…
ready + an extra on()
$(document).ready(function() { $.noop(); }).on('ready',function() { $.noop(); });
pending…
ready + on, no chaining
$(document).ready(function() { $.noop(); });

$(document).on('ready',function() {$.noop(); });
pending…
ready shortcut
$(function() { jQuery.noop(); });
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment