Gmail Like Internet Connectivity Alert - Offline.js

Gmail Like Internet Connectivity Alert - Offline.js
File Size: 680 KB
Views Total:
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

Offline.js is a standalone and lightweight javascript library that automatically alerts your users when they've lost internet connectivity, like Gmail. It captures AJAX requests which were made while the connection was down, and remakes them when it's back up, so your app reacts perfectly.

It has a number of beautiful themes and requires no configuration. Disable your internet connection to see it in action on demo page!

See also:

Basic usage:

1. Include Offline.js script on your web page/app.

<script src="js/snake.js"></script>

2. Pick and include a theme CSS on the page.

<link rel="stylesheet" href="../themes/offline-theme-chrome.css" />

3. Configurations.

<script>
Offline.options = {
// Should we check the connection status immediatly on page load.
checkOnLoad: false,

// Should we monitor AJAX requests to help decide if we have a connection.
interceptRequests: true,

// Should we automatically retest periodically when the connection is down (set to false to disable).
reconnect: {
// How many seconds should we wait before rechecking.
initialDelay: 3,

// How long should we wait between retries.
delay: (1.5 * last delay, capped at 1 hour)
},

// Should we store and attempt to remake requests which fail while the connection is down.
requests: true

// Should we show a snake game while the connection is down to keep the user entertained?
// It's not included in the normal build, you should bring in js/snake.js in addition to
// offline.min.js.
game: false
}

</script>

4. You're done. Check the document page for more advanced usages.


This awesome jQuery plugin is developed by hubspot. For more Advanced Usages, please check the demo page or visit the official website.