text: 
  function hasSWSupport () {
      return !!("serviceWorker" in navigator);
  }
  
  if (hasSWSupport())
  {
      var registration = navigator.serviceWorker.register("/service-worker.js");
  
      registration.then(function (registration)
      {
          // Registration was successful
          console.log("ServiceWorker registration successful with scope: ", registration.scope);
      }).catch(function (err)
      {
          // registration failed :(
          console.log("ServiceWorker registration failed: ", err);
      });
  }
  