-
Notifications
You must be signed in to change notification settings - Fork 846
Offline.js not working with async #266
Comments
True, but we are open to anyone who might want to show the project some love. |
Saw this issue whilst checking out another issue. Can I propose this instead... Here is the original code:
Here's what I'd do, since
P.S. Pretty sure I missed a bracket somewhere |
P.S.S. If it sounds good to you guys, I can submit a pull req. if you like. |
I tested the code, seems that it works pretty well. |
Yeah, the project isn't actively maintained. but may be I will help to someone newbile like me to solve the problem.
if you load your js asynchronously, this code will not work, as in most cases the init() function will never fire.
just change the code
, "complete" === document.readyState ? init() : null != document.addEventListener ? document.addEventListener("DOMContentLoaded", init, !1) :(_onreadystatechange = document.onreadystatechange, document.onreadystatechange = function() { return "complete" === document.readyState && init(), "function" == typeof _onreadystatechange ? _onreadystatechange.apply(null, arguments) :void 0; });
with:
, "complete" === document.readyState ? init() : interval = setInterval(function() { if(document.readyState === 'complete') { clearInterval(interval); init() } }, 100);
Yes its 2018, and years we still looking to figure out if the document has completed loading...
The text was updated successfully, but these errors were encountered: