Skip to content

Instantly share code, notes, and snippets.

@vmasek
Last active January 22, 2018 16:28
Show Gist options
  • Save vmasek/55e08b1d0ea41190ca5860685c6c20a0 to your computer and use it in GitHub Desktop.
Save vmasek/55e08b1d0ea41190ca5860685c6c20a0 to your computer and use it in GitHub Desktop.
title tags slideOptions
PWA
PWA, Angular, ngBeer
theme transition progress
simple
fade
true

Progressive Web Apps

by Vojtech Mašek Head dev @FlowUp github.com/vmasek


Reliable load instantly and never show the downasaur, even in uncertain network conditions

Fast respond quickly, 53% of users will abandon a site if it takes longer than few seconds to load

Engaging feel like a native app

This is what earns them a place on the user's home screen

Google Developers - Progressive Web Apps


Service worker

  • script that browser runs in the background, separate from a web page
  • written in JavaScript like a client-side proxy
  • puts you in control of the cache and how to respond to resource requests
  • allows pre-caching key resources
  • helps eliminate the dependence on the network
  • provides instant and reliable experience

Service Workers: an Introduction


Advantages of Mobile web

  • Immediacy - instantly available
  • Find ability - can be found easily
  • Reach - users visit hunderds of sites per month
  • Compatibility - across multiple devices *
  • Linkable - share via URL, does not require complex installation
  • SEO - contents can be indexed by search engines
  • Low friction - you need just a browser

Prerequisites

  • browser support
  • HTTPS
  • responsive app
  • optimized app
    • service workers can do pretty magical things on the browser side, but it cannot solve the problems within the app implementation

Browser

  • Chrome
  • Firefox
  • Opera
  • Microsoft Edge (In development) *
  • Safari (In development) *

* supported in development preview is Service Worker ready info site


![](https://i.imgur.com/zmwB89q.png =320x180)

Lighthouse is an open-source, automated tool for improving the quality of web pages. You can run it against any web page. It has audits for performance, accessibility, progressive web apps, and more.


Angular CLI 1.6

  • full Service worker support
  • easy integration
    • generated for a new project ng new my-project --service-worker
    • step by step guide for existing projects

Best way to start with service workers in your project is with this guide

angular.io/guide/service-worker-getstart


Example Angular project FeedGist

  • sw-precache
    • generates a service worker that precaches resources
    • integrates with build process
    • hash of each file
  • sw-toolbox and runtime caching
    • common caching strategies for dynamic content (APIs)
    • helps generate app shell

  • Offline Caching
  • Offline Analytics
    • collects analytics while offline and send them to Google Analytics when online
  • broadcast cache update
  • cache expiration
  • routing
  • runtime caching

PWAs in real life

Twitter Aliexpress Forbes Pinterest Washington Post Dev.to Wiki offline ...and many more to come

pwa.rocks


Pinterest case study

First paint Interactive
Old site 4.2s 23s
New site (PWA) 1.8s 5.6s
Repeated loads (PWA) 0.6s 3.9s

A Pinterest PWA pperformance case study


Size comparation (Pinterest case study)
platform size
Android 9.6 MB
iOS 56 MB
PWA 150 Kb

PWA loads routes on demand and the cost of additional code is amortized over the lifetime of the application. Subsequent navigations still don’t cost as much data as the download of the app.



Links

Service Workers: an Introduction

Google Developers - Progressive Web Apps

Angular service worker creating automatic PWAs

Angular PWA With 100 Lighthouse Score

What is PWA and why should you care?

Awesome PWA repo


Thanks for an attention

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment