Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Delay the result of the readyState check to give scripts the opportun…
- Loading branch information
Showing
1 changed file
with
2 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -429,7 +429,8 @@ jQuery.extend({ | ||
// Catch cases where $(document).ready() is called after the | ||
// browser event has already occurred. | ||
if ( document.readyState === "complete" ) { | ||
return jQuery.ready(); | ||
// Handle it asynchronously to allow scripts the opportunity to delay ready | ||
return setTimeout( jQuery.ready, 13 ); | ||
This comment has been minimized.
This comment has been minimized.
jeresig
Author
Member
|
||
} | ||
|
||
// Mozilla, Opera and webkit nightlies currently support this event | ||
Why 13ms? From @jrburke's comment it seems that jQuery.ready just needs to be pushed to the end of the call stack; the delay doesn't matter.
From what I've read, Chrome can execute an interval/timeout as quickly as 1ms, Firefox at 10ms or ~15ms, and IE at 15ms (src: http://code.google.com/p/chromium/issues/detail?id=888#c4). In this case, where we don't care about UI responsiveness, I think a 1ms or 0 ms interval is appropriate.