From 2d2dc5a4179a98824abc2de3b4d589378cfd14ab Mon Sep 17 00:00:00 2001 From: Ihor Sviziev Date: Thu, 30 Jul 2020 11:01:19 +0300 Subject: [PATCH] Fix long delay Port changes from jQuery Related to #1 #18 --- domReady.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/domReady.js b/domReady.js index 17a4ad4..10748fc 100644 --- a/domReady.js +++ b/domReady.js @@ -77,18 +77,12 @@ define(function () { } } - //Check if document already complete, and if so, just trigger page load - //listeners. Latest webkit browsers also use "interactive", and - //will fire the onDOMContentLoaded before "interactive" but not after - //entering "interactive" or "complete". More details: - //http://dev.w3.org/html5/spec/the-end.html#the-end - //http://stackoverflow.com/questions/3665561/document-readystate-of-interactive-vs-ondomcontentloaded - //Hmm, this is more complicated on further use, see "firing too early" - //bug: https://github.com/requirejs/domReady/issues/1 - //so removing the || document.readyState === "interactive" test. - //There is still a window.onload binding that should get fired if - //DOMContentLoaded is missed. - if (document.readyState === "complete") { + // Catch cases where $(document).ready() is called + // after the browser event has already occurred. + // Support: IE6-10 + // Older IE sometimes signals "interactive" too soon + if (document.readyState === "complete" || + (document.readyState !== "loading" && !document.documentElement.doScroll)) { pageLoaded(); } }