Lazy Load – $(document).ready?

Can I just use jQuery’s $(document).ready(function(){ //content }); and a quick solution for lazy loading?

Related posts

Leave a Reply

2 comments

  1. $(document).ready does not give lazy loading. What it does is wait for the page elements to finish loading before running the script – which is very useful and important when the code is manipulating elements in the page.

    Lazy loading strictly would involve loading parts of the page or the data only on demand, only when needed. If you actually need lazy loading, you need to do it properly. If you just need the page elements to have loaded then $(document).ready is fine.

  2. All the handlers passed to $(document).ready method are executed once the DOM in ready so it is not going to help with lazy loading. For lazy loading you might have to write your own logic.