1

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

3
  • 1
    Can you give a little more detail? Commented Jul 26, 2011 at 18:19
  • Our stat and ads JS hold up the page load so I want those two things to load after everything else. Commented Jul 26, 2011 at 18:55
  • 2
    Then you don't want lazy loading, but you do want $(document).ready processing. With some care, this can be done nicely from this. Commented Jul 26, 2011 at 21:25

2 Answers 2

3

$(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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.