Question: I have following jquery code in client side JS

```
// Following gets executed at document.ready() time

    $(function() {
      prepareCurList();
    });

// When does the following code gets executed as its just a plain JS statement???

    prepareNextList();

```

Please provide pointers.

Answer: 
The following code is executed right after executing `$(function() { })`. 

`$(function () {})` is just **registering** a handler to be executed on document ready, but the handler itself will not be executed until document is ready.
Here's a quick demonstration: <http://jsfiddle.net/PwsPv/>

```
console.log(1);                 // 1
$(function(){
  console.log(5);               // 5
});
$(document).ready(function(){
  console.log(6);               // 6
});
console.log(2);                 // 2
$(window).on("load",function(){
  console.log(7);               // 7
});
console.log(3);                 // 3
$(window).on("load",function(){
  console.log(8);               // 8
});
console.log(4);                 // 4

```