Guest User

Untitled

a guest
Oct 24th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. if ('serviceWorker' in navigator) {
  2. // Chrome, Firefox, Opera and Edge (16)
  3.  
  4. /*
  5. * scope (optional) default to the page root where it has been registered
  6. * */
  7.  
  8. navigator.serviceWorker.register('/sw.js', {scope: './'}).then(function(registration) {
  9. console.log('Service worker registration succeeded:', registration);
  10. }).catch(function(error) {
  11. console.log('Service worker registration failed:', error);
  12. });
  13. } else {
  14. // IE, Safari
  15. console.log('Service workers are not supported.');
  16. }
Add Comment
Please, Sign In to add comment