This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const APP = { | |
| SW: null, | |
| init() { | |
| //called after DOMContentLoaded | |
| APP.registerSW(); | |
| document.querySelector('h2').addEventListener('click', APP.addImage); | |
| }, | |
| registerSW() { | |
| if ('serviceWorker' in navigator) { | |
| // Register a service worker hosted at the root of the site |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const APP = { | |
| SW: null, | |
| init() { | |
| //called after DOMContentLoaded | |
| //register the service worker | |
| APP.registerSW(); | |
| //add click listener for h2 to load a new image | |
| document.querySelector('h2').addEventListener('click', APP.addImage); | |
| }, | |
| registerSW() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const APP = { | |
| SW: null, | |
| init() { | |
| //called after DOMContentLoaded | |
| if ('serviceWorker' in navigator) { | |
| // 1. Register a service worker hosted at the root of the | |
| // site using the default scope. | |
| navigator.serviceWorker | |
| .register('/sw.js', { | |
| scope: '/', |