Sometimes the user might a have a bad internet connection which may cause your site to not function properly. So it sounds like a good idea to let your user know when the internet goes off.
And guess what? It is really easy to do using navigator.connection. Here is a basic example.
navigator.connection.onchange = function(){
if(navigator.onLine){
alert("Your internet connection is back");
}else{
alert("Your currently offline");
}
}