Slide 1

Slide 1 text

Getting Everybody Online with PWAs - Orjiewuru Kingdom Isaac, DevFestSW17

Slide 2

Slide 2 text

What is a PWA? A Progressive Web App (PWA) is a web app that uses modern web capabilities to deliver an app-like experience to users. They are installable and live on the user's home screen, without the need for an app store.

Slide 3

Slide 3 text

Why the web? 5b devices are connected to the web

Slide 4

Slide 4 text

Why do we need progressive web apps? A lot of people visit the web from their mobile devices, but only a few keep returning. Most people visit the web in passing, this means that it is not their primary means of accessing the web.

Slide 5

Slide 5 text

4.0 Mobile apps Monthly Unique Visitors (M) 11.4 Mobile web Source comScore Mobile Metrix US, Age 18+, June 2016

Slide 6

Slide 6 text

#thoughts These numbers are encouraging, so let’s build more responsive web apps.

Slide 7

Slide 7 text

But how long do these visitors spend on mobile apps compared to mobile web?

Slide 8

Slide 8 text

188.6 Mobile apps Average minutes per visitor 9.3 Mobile web Source comScore Mobile Metrix US, Age 18+, June 2016

Slide 9

Slide 9 text

Visitors Engagement

Slide 10

Slide 10 text

We need a way to retain visitors by providing them with an engaging experience

Slide 11

Slide 11 text

We need PWAs

Slide 12

Slide 12 text

Why PWA?

Slide 13

Slide 13 text

Reliable Loads instantly even in shaky internet connections.

Slide 14

Slide 14 text

Fast Once a PWA is loaded, the experience is fast. Note: Apps are not fast by default so you need to build the app with speed in mind.

Slide 15

Slide 15 text

Engaging ● They appear in app drawer(menu) and home screen ● Immersive full screen experience with the help of manifest file ● Re-engage users with the help of push notifications

Slide 16

Slide 16 text

/* A little aside on speed

Slide 17

Slide 17 text

* RAIL - user-centric model for measuring performance Read Article here - http://bit.ly/2AKwR3u Paul Irish & Paul Lewis - October 2015

Slide 18

Slide 18 text

Back to business */

Slide 19

Slide 19 text

Building a PWA

Slide 20

Slide 20 text

manifest.json The web app manifest provides information about an application (such as name, author, icon, and description) in a JSON text file. The purpose of the manifest is to install web applications to the homescreen of a device, providing users with quicker access and a richer experience. - Mozilla (mzl.la/2lefIbe)

Slide 21

Slide 21 text

Configuring a PWA - manifest.json { "short_name": "Sample PWA", "name": "Sample PWA App DevFestSW", }

Slide 22

Slide 22 text

Configuring a PWA - manifest.json { "short_name": "Sample PWA", "name": "Sample PWA App DevFestSW", "icons": [{ "src": "launcher-icon-4x.png","sizes": "192x192" }], }

Slide 23

Slide 23 text

Configuring a PWA - manifest.json { ... "start_url": "index.html?launcher=true", }

Slide 24

Slide 24 text

Configuring a PWA - manifest.json { ... "display": "standalone", "theme_color": "#FF9800" }

Slide 25

Slide 25 text

A service worker is a script that your browser runs in the background, separate from a web page, opening the door to features that don't need a web page or user interaction. Service Worker

Slide 26

Slide 26 text

const cacheName = 'sample-pwa'; const filesToCache = ['/','/index.html','/styles.css']; self.addEventListener('install', function(e) { console.log('[ServiceWorker] Install'); e.waitUntil( caches.open(cacheName).then(function(cache) { console.log('[ServiceWorker] Caching app shell'); return cache.addAll(filesToCache); }) ); }); ... Configuring a PWA - service-worker.js

Slide 27

Slide 27 text

... self.addEventListener('activate', event => { event.waitUntil(self.clients.claim()); }); self.addEventListener('fetch', event => { event.respondWith( caches.match(event.request, {ignoreSearch:true}).then(response => { return response || fetch(event.request); }) ); }); Configuring a PWA - service-worker.js

Slide 28

Slide 28 text

Adding the service worker and manifest files ... if('serviceWorker' in navigator) { navigator.serviceWorker.register('/sw.js') .then(function() { console.log('Service Worker Registered'); }); } ...

Slide 29

Slide 29 text

Demo

Slide 30

Slide 30 text

Who uses PWAs

Slide 31

Slide 31 text

Questions ?

Slide 32

Slide 32 text

Thanks