Slide 1

Slide 1 text

PROGRESSIVE WEB APPLICATIONS @hdjirdeh

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

WEBPAGE INGREDIENT INGREDIENT INGREDIENT INGREDIENT INGREDIENT INGREDIENT

Slide 5

Slide 5 text

PWAs use modern web capabilities to provide a reliable, engaging and fast user experience on any device reliable engaging fast on any device

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

NETWORK CONNECTION IS SECURE

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

CAN WORK WITH POOR/NO CONNECTION

Slide 11

Slide 11 text

DOWNASAUR

Slide 12

Slide 12 text

Service workers

Slide 13

Slide 13 text

A service worker is a script that runs in the background of your browser when you view a webpage

Slide 14

Slide 14 text

ADDING A SERVICE WORKER 1. Create the file and write the logic yourself 2. Use a library

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

npm install workbox-cli --global workbox-cli generate:sw

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

if ('serviceWorker' in navigator) { window.addEventListener('load', function () { navigator.serviceWorker.register('/service-worker.js').then(function(){ // Registration was successful console.log('ServiceWorker registration successful!'); }).catch(function(err) { // registration failed :( console.log('ServiceWorker registration failed: ', err); }); }); } if ('serviceWorker' in navigator) { window.addEventListener('load', function () { navigator.serviceWorker.register('/service-worker.js') if ('serviceWorker' in navigator) { window.addEventListener('load', function () { navigator.serviceWorker.register('/service-worker.js').then(function(){ // Registration was successful console.log('ServiceWorker registration successful!'); }).catch(function(err) { // registration failed :( console.log('ServiceWorker registration failed: ', err); }); }); } if ('serviceWorker' in navigator) { window.addEventListener('load', function () { navigator.serviceWorker.register('/service-worker.js').then(function(){ // Registration was successful console.log('ServiceWorker registration successful!'); }).catch(function(err) { // registration failed :( console.log('ServiceWorker registration failed: ', err); }); }); }

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

APPLICATION SHELL

Slide 21

Slide 21 text

APPLICATION SHELL CONTENT

Slide 22

Slide 22 text

module.exports = { globDirectory: 'dist/', globPatterns: ['**/*.{js,png,svg,html,json}'], swDest: 'dist/service-worker.js', navigateFallback: '/index.html' }; module.exports = { globDirectory: 'dist/', globPatterns: ['**/*.{js,png,svg,html,json}'], swDest: 'dist/service-worker.js', navigateFallback: '/index.html', }; module.exports = { globDirectory: 'dist/', globPatterns: ['**/*.{js,png,svg,html,json}'], swDest: 'dist/service-worker.js', navigateFallback: '/index.html' }; globDirectory: 'dist/' globPatterns: ['**/*.{js,png,svg,html,json}'] swDest: 'dist/service-worker.js' navigateFallback: '/index.html'

Slide 23

Slide 23 text

BUILD PROCESS

Slide 24

Slide 24 text

npm install workbox-cli --save-dev // package.json "scripts": { //... "build": "{build} && workbox-cli generate:sw" }

Slide 25

Slide 25 text

workbox-webpack-plugin

Slide 26

Slide 26 text

DYNAMIC CONTENT

Slide 27

Slide 27 text

module.exports = { globDirectory: 'dist/', globPatterns: ['**/*.{js,png,svg,html,json}'], swDest: 'dist/service-worker.js', navigateFallback: '/index.html', runtimeCaching: [ { urlPattern: /^https:\/\/your.api.com\/.*/, handler: 'networkFirst' } ] }; module.exports = { globDirectory: 'dist/', globPatterns: ['**/*.{js,png,svg,html,json}'], swDest: 'dist/service-worker.js', navigateFallback: '/index.html', runtimeCaching: [ { urlPattern: /^https:\/\/your.api.com\/.*/, handler: 'networkFirst' } ] }; runtimeCaching: [ { urlPattern: /^https:\/\/your.api.com\/.*/, handler: 'networkFirst' } ] runtimeCaching: [ { urlPattern: /^https:\/\/your.api.com\/.*/, handler: 'networkFirst' } ] networkFirst

Slide 28

Slide 28 text

networkFirst cacheFirst fastest cacheOnly networkOnly

Slide 29

Slide 29 text

APP SHELL + DYNAMIC CACHING

Slide 30

Slide 30 text

OFFLINE SUPPORT + FASTER REPEAT VISITS

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

preview.starbucks.com

Slide 33

Slide 33 text

CAN I HAZ? Under development

Slide 34

Slide 34 text

PAGE LOAD IS FAST

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

CSS JS PNG

Slide 37

Slide 37 text

Slide 38

Slide 38 text

JS JS

Slide 39

Slide 39 text

as="script" as="style" as="font" as="audio" as="image" as="video"

Slide 40

Slide 40 text

Slide 41

Slide 41 text

preload-webpack-plugin

Slide 42

Slide 42 text

CAN I HAZ? Partial Support

Slide 43

Slide 43 text

HTTP/2 Server Push

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

Link: ; rel=preload; as=style Link: ; rel=preload; as=script

Slide 47

Slide 47 text

No content

Slide 48

Slide 48 text

Link: ; rel=preload; as=style; nopush Link: ; rel=preload; as=script

Slide 49

Slide 49 text

A Comprehensive Guide To HTTP/2 Server Push - Jeremy Wagner https://rebrand.ly/http2

Slide 50

Slide 50 text

Pushing too much Pushing unused assets Cache?

Slide 51

Slide 51 text

Service Worker H2 Push

Slide 52

Slide 52 text

BUNDLES

Slide 53

Slide 53 text

4KB - 145KB Size of JS frameworks, gzipped Restuta/framework-sizes.md GIST

Slide 54

Slide 54 text

CODE SPLITTING

Slide 55

Slide 55 text

export const routes: Routes = [ { path: '', redirectTo: 'main', pathMatch: 'full' }, { path: 'main', component: MainComponent }, { path: 'details', loadChildren: 'details/details.module#DetailsModule' } ]; export const routes: Routes = [ { path: '', redirectTo: 'main', pathMatch: 'full' }, { path: 'main', component: MainComponent }, { path: 'details', loadChildren: 'details/details.module#DetailsModule' } ]; loadChildren: 'details/details.module#DetailsModule'

Slide 56

Slide 56 text

import Loadable from 'react-loadable'; import Loading from './loading.component'; const LoadableComponent = Loadable({ loader: () => import('./details.component'), loading: Loading, });

Slide 57

Slide 57 text

No content

Slide 58

Slide 58 text

WEBPACK BUNDLE ANALYZER

Slide 59

Slide 59 text

bundlesize

Slide 60

Slide 60 text

FIRST MEANINGFUL PAINT TIME TO INTERACTIVE

Slide 61

Slide 61 text

SHOW SOME CONTENT WITHOUT JAVASCRIPT

Slide 62

Slide 62 text

Sorry, JavaScript needs to be enabled in order to run this application.

Slide 63

Slide 63 text

SERVER SIDE RENDERING

Slide 64

Slide 64 text

INSTALL ON YOUR DEVICE

Slide 65

Slide 65 text

Slide 66

Slide 66 text

{ name: "Angular 2 HN", short_name: "Angular 2 HN", icons: [ { src: "assets/icons/android-chrome-192x192.png", sizes: "192x192", type: "image/png" }, // ... ], theme_color: "#b92b27", background_color: "#ffffff", display: "standalone", orientation: "portrait" }

Slide 67

Slide 67 text

APP INSTALL BANNER

Slide 68

Slide 68 text

INSTALL TO HOMESCREEN

Slide 69

Slide 69 text

SPLASH SCREEN

Slide 70

Slide 70 text

APP LOADED

Slide 71

Slide 71 text

CAN I HAZ? Under development

Slide 72

Slide 72 text

SAFARI ON IOS Can install to homescreen but that’s it…

Slide 73

Slide 73 text

Slide 74

Slide 74 text

No content

Slide 75

Slide 75 text

No content

Slide 76

Slide 76 text

Native Progressive Web

Slide 77

Slide 77 text

Progressive web apps can replace native apps

Slide 78

Slide 78 text

@hdjirdeh