jQuery document on vs ready

JavaScript performance comparison

Revision 6 of this test case created

Preparation code

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

<table data-foo="True">
<tr>
  <th>Hello</th><td>World</td>
</tr>
</table>

<table data-bar="True">
<tr>
  <th>Hello</th><td>World</td>
</tr>
</table>

<table data-hax="True">
<tr>
  <th>Hello</th><td>World</td>
</tr>
</table>

<table data-fax="True">
<tr>
  <th>Hello</th><td>World</td>
</tr>
</table>

Preparation code output

HelloWorld
HelloWorld
HelloWorld
HelloWorld

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(ready)
$(document).on('ready',function () {
  $('[data-foo] td').css('background','red');
});
pending…
ready
$(document).ready(function () {
  $('[data-bar]').find('td').css('background','yellow')
});
pending…
on(), object in context
$(document).on('ready','[data-hax]', function () {
  $(this).find('td').css('background','green');
  $(this).find('td').html($(this).html());
});
pending…
$(document).on('load','[data-fax]', function () {
  $(this).find('td').css('background','green');
  $(this).find('td').html($(this).html());
});
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