I’ve been noticing that when my single-page HTML5 application loads, the class I wrote to monitor the status of the application cache on page load occasionally goes out to lunch and hangs the page during bootstrapping.
The Mozilla docs on Application Cache are pretty good. https://developer.mozilla.org/en-US/docs/HTML/Using_the_application_cache?redirectlocale=en-US&redirectslug=Offline_resources_in_Firefox#Enabling_the_application_cache
Towards the bottom is this little gem however:
The problem with this advice is that simply reading window.applicationCache.status after registering your app cache monitoring event handlers does not provide enough context to determine what to do correctly. Here’s the dilemma:
Status == IDLE implies possible OFFLINE or NOUPDATE. If you provide custom logic for each case, the difference matters.
But you can’t know which of these might have happened unless you know if any of your event handlers are called. And of course none of them are ever called until after you return from the function that registers the handlers. So you can’t do the right thing in that function it seems.
Perhaps I missed something but it seems like you have to set a watchdog timer and check both the browser’s application cache status and the status of your event handler callbacks to determine if it’s necessary to manually invoke one of the event listener callbacks in order to get the page to bootstrap normally.