ready function or put JS at end of page

ready function or put JS at end of page

I originally thought I should always include js which shouldn't be parsed until the html had been written using the following:
 $(document).ready(function () {
//My code
});


I later read that I shouldn't do this (JQuery Cookbook, or something similar) but instead should just include my JS at the very end of the page but before the body close tag.

Any comments which is best?

Thanks