I am using lazy load jquery plugin.
It tells me to put this in my code to activate it:
$("img").lazyload();
Do I have to put this in $(document).ready()? or can I just put it at the very top of the page:
<head>
<script type="text/javascript">
$("img").lazyload();
$(document).ready...{}
</script>
</head>
The demo page puts it in the $(document).ready(), except it uses the shorthand $( ) function to do it.
(from the demo)
(note that $() is an alias to the jQuery() function, which takes CSS selectors, HTML elements and also callbacks to run when the DOM loads)
If you don’t put it in the ready() function, then it may only affect images that are earlier in the page than your script. And if you’re placing scripts in the HEAD, that’s none of the images.
So, unless the library is somehow using the .live() function of JQuery, you need to put it in ready().