Online State

Browsers expose a network connection availability information to the web application, so that the applications may react properly, i.e. stop all the operations utilising the network and switch to cached data when offline condition was detected.

API glimpse

navigator.onLine
Returns true when the browser detects network connection available, false otherwise.
window.addEventListener('online', listener)
An event fired when the browser detects network connection has become available.
window.addEventListener('offline', listener)
An event fired when the browser detects network connection has become unavailable.

Resources