The ability to use apps when not connected to the Internet is especially important for mobile devices, which may wander out of coverage areas. But it also matters for desktop systems, the common example being use on an airplane that lacks Wifi.
Several strategies and technologies can help ensure a good offline experience:
The primary way to make an app work offline is with an application cache, which stores resources for the app on the client system so that they are available when even when the Internet is not.
A key factor in working well offline is to check whether the device has connectivity and respond appropriately when it doesn't. Even a message to the user that the app won't work offline is better than getting stuck, or getting a generic time-out error.
The simplest way to do this is to check, and listen for changes to, the
window.navigator.onLine property. However, that value is not guaranteed to be accurate.
If you are using XMLHttpRequest to update data dynamically, you can check its response to determine if the network connection has dropped during the use of your app.