Maxim Salnikov
@webmaxru
Progressive Web Apps — what are the advantages
Developer Audience Lead at Microsoft
A useful design pattern, not a formalized standard.
* but not everything**
** use progressive enhancement strategy
My App
App
Service-worker
Browser/OS
Event-driven worker
Cache
fetch
push
sync
self.addEventListener('install', event => {
// Use Cache API to cache html/js/css
})
self.addEventListener('activate', event => {
// Clean the cache from the obsolete versions
})
self.addEventListener('fetch', event => {
// Serve assets from cache or network
})// Setting up an application shell
precacheAndRoute(self.__WB_MANIFEST);
// Runtime caching API calls
registerRoute(
({ url }) => url.hostname.includes("/api/"),
new StaleWhileRevalidate()
);
// Your own listeners
self.addEventListener("push", (event) => {});Service Worker with "fetch"
Web App Manifest
{
{
"name": "My PWA",
"start_url": "/",
"icons": [{
"src": "icons/512x512.png",
"sizes": "512x512",
"type": "image/png"
}]
}"shortcuts": [{
"name": "Upload Audio File",
"url": "/upload-mp3",
"icons": [{
"src": "/icon-mp3.png",
"sizes": "192x192"
}]
}]{
"display":
"fullscreen" |
"standalone" |
"minimal-ui" |
"browser"
}titlebar-area-x
titlebar-area-y
titlebar-area-width
titlebar-area-height{
"display_override": "window-controls-overlay"
}{
"display_override": "tabbed"
}Maxim Salnikov
@webmaxru