JQuery methods are inside a document ready event.
$(document).ready(function(){
// jQuery methods
});
Here are some examples of actions that can fail if methods are run before the document is fully loaded:
1. Trying to hide an element that is not created yet.
2. Trying to get the size of an image that is not loaded yet.