It comes with multiple ready to use CSS styles and languages, so you pick a custom style that works for you. What does it do? Offline.js detects when you browser goes offline provides unobtrusive but noticeable alerts and extra information, like re-connection time if known. Offline.js is a really lightweight script (only 3kb in minified and compressed format) which works with no dependencies and is supported by modern versions Chrome, Firefox and IE (version 8 and above). Offline.js – Handle your users losing their internet connection like a pro Don’t worry though the aforementioned JavaScript library is here to help! This is a bit more of an issue because you won’t even notice something’s gone wrong until you try to preview your new content and the changes haven’t taken effect, because the only place you can see AJAX errors is in your browser console, which most of us aren’t inclined to check in the middle of writing. Of course, for the most part modern browsers will store stuff in its cache, offering a lifeline when you’re locked out of the net, but sometimes requests are sent via AJAX.
Every single one of us has encountered such an issue before it’s like a right of passage for any computer uses that at least once they lose part of their content because the server doesn’t respond or the network connection goes down. This functionality is easily leveraged via the navigator object provided by your browser, but if you’re not a fan of writing your own Javascript code there’s a ready-made alternative you can use the offline.js library.Īlright, so before we start adding libraries and generally making a mess we need to ask ourselves a question what possible benefit is there to detecting the browser state? Picture the situation you’re feverishly working on a long article or custom HTML code, and then when you click the "Save" button to store all your lovely work, something craps out on you and you’re left with a blank page where your work once was. One of JavaScript’s many features is the ability to detect whether a given browser is currently online or offline.