Re:Don’t let jQuery’s $(document).ready() slow you down
by Encosia on Thursday August 19, 2010 @07:26PM
(#1619018)
The way browsers implement both JavaScript and document rendering via a single-threaded execution queue, that isn't an issue. Once the page begins rendering, callbacks won't have a chance to execute until after the document is rendered and ready. That's the same mechanism that makes the setTimeout(fn, 0) trick work, for example.
It feels a bit like driving fast with no seat belt on, but it's safe.
If you do want to be extra cautious, MBlume's suggestion to wrap the success handler in $(document).ready() works fine too. That's effectively the same as not wrapping it.
It feels a bit like driving fast with no seat belt on, but it's safe.
If you do want to be extra cautious, MBlume's suggestion to wrap the success handler in $(document).ready() works fine too. That's effectively the same as not wrapping it.