building blazing fast progressive
web apps
matt busche
why a web app?
why a web app?
why a web app?
building a pwa
what is a progressive web app?
what is a progressive web app?
service worker support
what is a service worker
key features
key features
index.html
<link rel="manifest" href="/manifest.json">
manifest.json
{ "name": "Conference POC",
"short_name": "Conference",
"start_url": "index.html",
"display": "standalone",
"background_color": "#FCD116",
"theme_color": "#000000",
"description": "A POC of a Conference PWA",
"icons": [{
"src": "images/icons/icon-128x128.png",
"sizes": "128x128",
"type": "image/png"
}]
}
app shell
install the service worker
self.addEventListener('install',function(e) { �������});
self.addEventListener('install',function(e) { e.waitUntil(� caches.open(cacheName)� .then(function(cache)� � })� );�});
self.addEventListener('install',function(e) { e.waitUntil(� caches.open(cacheName)� .then(function(cache)� return cache.addAll(filesToCache);� })� );�});
caching techniques
cache names and what to cache
web push api
app.js
Notification.requestPermission()
.then(result => {
if (result === 'denied') {
console.log('Permission denied');
return;
}
// User has allowed push notifications
});
app.js
// Send PushSubscription details to server
getSWRegistration()
.then((registration) => {
const options = { … };
return registration.pushManager
.subscribe(options);
});
push.js
// PushSubscription details from client
webPush.sendNotification(
pushSubscription,
Payload
);
serviceworker.js
this.addEventListener('push',event => {
var title = 'push message';
event.waitUntil(this.registration
.showNotification(title, {
body: 'message',
icon: 'images/image.png',
tag: 'tag-name'
});
);
});
developer tools
questions?
resources