I have seen people do this way
$(window).load(function(){
});
also
$(document).ready(function() {
});
but some jquery still works outside these two functions, why?
Update
hmm. that means i can use $(window).load inside $(document).ready? or they should be seperated?
there are only stands for
.ready function to execute after the DOM is ready.
Will execute after the page along with all its contents are done loading. This means that all images, css.
If you are writing some JS code that does not depend on selecting DOM nodes or does not need the document to be fully loaded, you can and usually should put that code outside this block.