getting started with progressive web apps

51
Getting Started with Progressive Web Apps GDG Athens

Upload: bill-stavroulakis

Post on 11-Apr-2017

80 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Getting Started with Progressive Web Apps

Getting Started with Progressive Web AppsGDG Athens

Page 2: Getting Started with Progressive Web Apps

@bstavroulakis

bstavroulakis.comdotnetweekly.comfullstackweekly.com

Bill Stavroulakis

Page 3: Getting Started with Progressive Web Apps

Goals

What are Progressive Web Apps?

Build a very simple PWA

Page 4: Getting Started with Progressive Web Apps
Page 5: Getting Started with Progressive Web Apps
Page 6: Getting Started with Progressive Web Apps
Page 7: Getting Started with Progressive Web Apps
Page 8: Getting Started with Progressive Web Apps

Why Native Apps are a Gamble

● 60% of apps in the Google Play app store have never been downloaded.

● The average user downloads less than 3 apps per month. Half of US

smartphone users download zero apps per month.

● Mobile users spend most of their time in apps, but 94% of app revenue

comes from 1% of publishers, and users spend 80% of their time using just

5 apps.

● 80% of users who download an app fail to become active users.

● Worried about missing out on app store revenue? In app purchases are

where the money is at, and you can do that in your own app without

splitting costs with Apple or Google.

Page 9: Getting Started with Progressive Web Apps

Meanwhile, more than half of all web traffic comes from mobile. In other words, instead of downloading your app, users are using top apps like Facebook, Instagram, and Snapchat or browsing the web.

Page 10: Getting Started with Progressive Web Apps
Page 11: Getting Started with Progressive Web Apps
Page 12: Getting Started with Progressive Web Apps
Page 13: Getting Started with Progressive Web Apps

Case Studies

https://developers.google.com/web/showcase/

Page 14: Getting Started with Progressive Web Apps

Progressive Apps - Building Blocks

App-shell (Loads Instantly)

HTTPS (Safety)

App-like (Emulate Behavior, App-shell, Push Notifications)

Web (Crawlable and Discoverable)

Progressive Enhancements (Leverage Device)

Installable (Add to Homescreen)

Page 15: Getting Started with Progressive Web Apps

PWA Demo

https://bit.ly/pwa-car-deals

Page 16: Getting Started with Progressive Web Apps

Step by Step Demos

https://bstavroulakis.com/pluralsight/courses/progressive-web-apps/

Page 17: Getting Started with Progressive Web Apps

4 parts

git clone https://github.com/bstavroulakis/progressive-web-apps/

git reset --hard

App-shell git checkout 2-webapp-structure

Client-side Storage git checkout 3-client-side-storage

Service Worker git checkout 4-service-worker

Installable Web Apps git checkout master

Page 18: Getting Started with Progressive Web Apps

Part 1 - App-shell

Page 19: Getting Started with Progressive Web Apps

action1(function (value1) {

action2(value1, function(value2) {

action3(value2, function(value3) {

action4(value3, function(value4) {

// Do something with value4

});

});

});

});

Pyramid of Doom

Page 20: Getting Started with Progressive Web Apps

Part 2 - Client-side Storage

Page 21: Getting Started with Progressive Web Apps

Cookies

Compatibility Everywhere!

Size 4KB

Data-type String

Pros Simple, Configurable, Compatible

Cons Less secure, Limiting, Attaches to requests, Easily deleted

Page 22: Getting Started with Progressive Web Apps

HTML5 Web Storage

Compatibility Everywhere!

Size 2.5-5MB

Data-type String

Pros Simple, Not transmitted, Compatible

Cons Unstructured data, Slow access

Page 23: Getting Started with Progressive Web Apps

WebSQL

Compatibility Chrome, Safari, Opera, Strong mobile support

Size 2.5-5MB

Data-type String

Pros Asynchronous, Great search speed

Cons Deprecated, Steep learning curve, Schema pre-defined

Page 24: Getting Started with Progressive Web Apps

IndexedDB

Compatibility Modern browsers

Size 10-20% of available space (browser specific)

Data-type JS Object

Pros Asynchronous, Large dataset

Cons Steep learning curve, Complicated while implementing

Page 25: Getting Started with Progressive Web Apps

Storage Options

Cookies (Very Limiting)

HTML5 Local Storage (Limited Size)

WebSQL (Deprecated)

IndexedDB (Limited Support)

Page 26: Getting Started with Progressive Web Apps

Storage Options

Cookies (Very Limiting)

HTML5 Local Storage (Limited Size)

WebSQL (Deprecated)

IndexedDB (Limited Support)

Page 27: Getting Started with Progressive Web Apps

The Offline Journey Begins

Page 28: Getting Started with Progressive Web Apps

Application Cache Status

var appCache = window.applicationCache;

appCache.update();appCache.addEventListener('cached', handleCacheEvent, false);appCache.addEventListener('checking', handleCacheEvent, false);appCache.addEventListener('downloading', handleCacheEvent, false);appCache.addEventListener('error', handleCacheError, false);appCache.addEventListener('noupdate', handleCacheEvent, false);appCache.addEventListener('obsolete', handleCacheEvent, false);appCache.addEventListener('progress', handleCacheEvent, false);appCache.addEventListener('updateready', handleCacheEvent, false);

Page 29: Getting Started with Progressive Web Apps

Part 3 - Service Worker

Page 30: Getting Started with Progressive Web Apps

Service Worker

Separate Thread

Intercept Network Requests

Functional Events (fetch, push, sync)

Application Cache

Strict Rules

Bad Versioning

Cannot Update Small Areas

Page 31: Getting Started with Progressive Web Apps
Page 32: Getting Started with Progressive Web Apps
Page 33: Getting Started with Progressive Web Apps
Page 34: Getting Started with Progressive Web Apps
Page 35: Getting Started with Progressive Web Apps

No DOM Access

No Page

Global Script Context

HTTPS

Run Without a Page!!

Event-driven

Page 36: Getting Started with Progressive Web Apps
Page 37: Getting Started with Progressive Web Apps

Installed/ Waiting

Page 38: Getting Started with Progressive Web Apps

skipWaiting()

Page 39: Getting Started with Progressive Web Apps

clients.claim()

Page 40: Getting Started with Progressive Web Apps
Page 41: Getting Started with Progressive Web Apps

Network Only Strategy

Page 42: Getting Started with Progressive Web Apps

Network First Then Offline Strategy

Page 43: Getting Started with Progressive Web Apps

Network First Then Offline Strategy

Page 44: Getting Started with Progressive Web Apps

Offline First Then Network Strategy

Page 45: Getting Started with Progressive Web Apps

Offline Only Strategy

Page 46: Getting Started with Progressive Web Apps

Part 4 - Installable Web Apps

Page 47: Getting Started with Progressive Web Apps

Visit Twice

Manifest.json

Meta-tag

Short_name

Start_url

144x144

Service Worker

HTTPS

Page 48: Getting Started with Progressive Web Apps

Deeply Integrated Apps

https://www.xda-developers.com/deeply-integrated-progressive-web-apps-are-already-live-for-chrome-on-android/

Page 49: Getting Started with Progressive Web Apps

App-shell

Client-side Storage

Service Worker

Manifest.json

Summary

Page 50: Getting Started with Progressive Web Apps

http://bit.ly/2fP01mo

Page 51: Getting Started with Progressive Web Apps

https://github.com/bstavroulakis/progressive-web-apps