Welcome Guest! (App Version 3.1)

websitnero logo name

Service Worker

Using Service Workers in HTML5

Service Workers are used for making better user experience in case of being Offline. Earlier many efforts have been made to solve this problem -- Google Gears, Dojo Offline, HTML5 AppCache, but all these failed to deliver on their promise and were unable to solve the problem. So, now Service Worker is a new step in this direction. Though, this seems a bit more complex than Application Cache (now deprecated), but is more promising for future implementations.


if('serviceWorker' in navigator){

  // Register service worker
    alert("SW registration succeeded. Scope is "+reg.scope);
    alert("SW registration failed with error "+err);



console.log('Started', self);

self.addEventListener('install', function(event) {
  console.log('Installed', event);

self.addEventListener('activate', function(event) {
console.log('Activated', event);

self.addEventListener('push', function(event) {
  console.log('Push message received', event);
WebsiteNero is highly optimized for learning various website developing technlogies. We try our best to add maximum modules and examples to help learn the concepts clearly and vividly. We try to present all content and examples as simple as we can removing any complexity to hurdle easy understanding. We try best provide you with worthful content, but we cannot guarantee full correctness of all the content on this site. While using this website, you agree to have read and accepted all our terms of use and conditions, cookie, and privacy policy. Copyright, 2013-2018 by websitenero.com. All Rights Reserved.