Skip to content

Instantly share code, notes, and snippets.

View Goshishah's full-sized avatar
🏠
Working from home

shujaat ali Goshishah

🏠
Working from home
  • Pakistan
View GitHub Profile
@prof3ssorSt3v3
prof3ssorSt3v3 / app.js
Last active August 22, 2024 12:33
Code from Service Workers 4 - integrating the cache api with a service worker
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
@prof3ssorSt3v3
prof3ssorSt3v3 / app.js
Created March 9, 2021 21:50
Code from Service Workers 3 - self.skipWaiting, ev.waitUntil, and clients.claim
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() {
@prof3ssorSt3v3
prof3ssorSt3v3 / app.js
Created March 8, 2021 18:13
Introduction to Service Workers code from video
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: '/',