Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ('serviceWorker' in navigator) {
- // Chrome, Firefox, Opera and Edge (16)
- /*
- * scope (optional) default to the page root where it has been registered
- * */
- navigator.serviceWorker.register('/sw.js', {scope: './'}).then(function(registration) {
- console.log('Service worker registration succeeded:', registration);
- }).catch(function(error) {
- console.log('Service worker registration failed:', error);
- });
- } else {
- // IE, Safari
- console.log('Service workers are not supported.');
- }
Add Comment
Please, Sign In to add comment