SlideShare une entreprise Scribd logo
1  sur  79
Télécharger pour lire hors ligne
THE HITCHHIKER’S GUIDE TO
BUILDING A PROGRESSIVE WEB APP
Chris Nguyen
@uncompiled
https://pwa.rocks
SOURCE: https://pokedex.org
POKEDEX.ORG
PROGRESSIVE WEB APPS
● Progressive
● Responsive
● Linkable
● Fresh
● App-like
● Safe
● Discoverable
● Installable
● Re-engageable
● Connectivity independent
SOURCE: https://developers.google.com/web/fundamentals/getting-started/your-first-progressive-web-app/
PROGRESSIVE
ENHANCEMENT
PROGRESSIVE WEB APPS
✓ Progressive
● Responsive
● Linkable
● Fresh
● App-like
● Safe
● Discoverable
● Installable
● Re-engageable
● Connectivity independent
SOURCE: https://developers.google.com/web/fundamentals/getting-started/your-first-progressive-web-app/
RESPONSIVE
WEB DESIGN
PROGRESSIVE WEB APPS
✓ Progressive
✓ Responsive
● Linkable
● Fresh
● App-like
● Safe
● Discoverable
● Installable
● Re-engageable
● Connectivity independent
SOURCE: https://developers.google.com/web/fundamentals/getting-started/your-first-progressive-web-app/
LINKABLE
@slightlylate: "URLs are the web's superpower." #chromedevsummit
PROGRESSIVE WEB APPS
✓ Progressive
✓ Responsive
✓ Linkable
● Fresh
● App-like
● Safe
● Discoverable
● Installable
● Re-engageable
● Connectivity independent
SOURCE: https://developers.google.com/web/fundamentals/getting-started/your-first-progressive-web-app/
FRESH
CREDIT: http://www.slashfilm.com
CREDIT: Android Authority
PROGRESSIVE WEB APPS
✓ Progressive
✓ Responsive
✓ Linkable
✓ Fresh
● App-like
● Safe
● Discoverable
● Installable
● Re-engageable
● Connectivity independent
SOURCE: https://developers.google.com/web/fundamentals/getting-started/your-first-progressive-web-app/
APP-LIKE
APP-LIKE
● Familiar interface
● Fast screen transitions
● Smooth scrolling
● Feels native
SOURCE: https://app.ft.com
PROGRESSIVE WEB APPS
✓ Progressive
✓ Responsive
✓ Linkable
✓ Fresh
✓ App-like
● Safe
● Discoverable
● Installable
● Re-engageable
● Connectivity independent
SOURCE: https://developers.google.com/web/fundamentals/getting-started/your-first-progressive-web-app/
SAFE
SAFE
● Must be served using HTTPS
● Prevents snooping or MITM attacks
● Privacy and security for users
White House OMB Memorandum 15-13
SOURCE: https://https.cio.gov
White House OMB Memorandum 15-13
SOURCE: https://https.cio.gov
PROGRESSIVE WEB APPS
✓ Progressive
✓ Responsive
✓ Linkable
✓ Fresh
✓ App-like
✓ Safe
● Discoverable
● Installable
● Re-engageable
● Connectivity independent
SOURCE: https://developers.google.com/web/fundamentals/getting-started/your-first-progressive-web-app/
DISCOVERABLE
WEB APPLICATION MANIFEST
{
"name": "My Web Application",
"short_name": "My App",
"description": "A Simple Progressive Web App",
"icons": [
...
{
"src": "launcher-icon-4x.png",
"sizes": "192x192",
"type": "image/png"
}
],
"start_url": "/index.html",
"display": "standalone",
"orientation": "portrait"
}
<link rel="manifest" href="/manifest.json">
PROGRESSIVE WEB APPS
✓ Progressive
✓ Responsive
✓ Linkable
✓ Fresh
✓ App-like
✓ Safe
✓ Discoverable
● Installable
● Re-engageable
● Connectivity independent
SOURCE: https://developers.google.com/web/fundamentals/getting-started/your-first-progressive-web-app/
INSTALLABLE
CREDIT: https://xkcd.com/1367/
INSTALLABLE
● Multiple visits
trigger prompt
● Low friction
● No app store
SOURCE: https://www.devfestdc.rocks
PROGRESSIVE WEB APPS
✓ Progressive
✓ Responsive
✓ Linkable
✓ Fresh
✓ App-like
✓ Safe
✓ Discoverable
✓ Installable
● Re-engageable
● Connectivity independent
SOURCE: https://developers.google.com/web/fundamentals/getting-started/your-first-progressive-web-app/
RE-ENGAGEABLE
https://gauntface.github.io/simple-push-demo/
PROGRESSIVE WEB APPS
✓ Progressive
✓ Responsive
✓ Linkable
✓ Fresh
✓ App-like
✓ Safe
✓ Discoverable
✓ Installable
✓ Re-engageable
● Connectivity independent
SOURCE: https://developers.google.com/web/fundamentals/getting-started/your-first-progressive-web-app/
CONNECTIVITY
INDEPENDENT
MOBILE NETWORKS ARE UNRELIABLE
● LTE service isn’t always LTE
● Mobile devices constantly transfer between
antennas, 3G, LTE, and Wi-Fi
● Slow response is worse than fast connection
failure
SOURCE: https://hpbn.co
LATENCY: THE NEW WEB PERFORMANCE BOTTLENECK
SOURCE: https://www.igvita.com/2012/07/19/latency-the-new-web-performance-bottleneck/
MOBILE-FIRST WEB DEVELOPMENT
● Responsive Web Design
○ Addresses the mobile user interface
● Service Worker API
○ Addresses the mobile network
● Design for slow mobile devices and slow networks
○ It’ll be ⚡ on high-end phones and fast networks
CREDIT: MTV
SERVICE WORKER
● Client-side programmable network proxy
● Registered against a domain & path
○ www.devfestdc.org != images.devfestdc.org
○ www.devfestdc.org != www.devfestdc.org/js
● Intercept network requests
● Gives developers control of network failure
OFFLINE SUPPORT
(USING A SERVICE WORKER)
DEVFESTDC.ORG: INSTALL SERVICE WORKER
● Register a service worker for www.devfestdc.org
● Install at root scope (“/”) so it can handle the entire site
if('serviceWorker' in navigator) {
navigator.serviceWorker
.register('/sw.js')
.then(function() { console.log('Service Worker Registered'); });
}
DEVFESTDC.ORG: CACHE ASSETS
● Inside “/sw.js”, cache all the assets
● Include all HTML, CSS, and JS required to load the site
self.addEventListener('install', function(event) {
event.waitUntil(
caches.open('devfestdc-static-v1').then(function(cache) {
return cache.addAll(['/index.html', '/js/all.min.js', ... /* etc */ ]);
});
);
});
DEVFESTDC.ORG: RESPOND WITH CACHED ASSETS
● Inside “/sw.js”, add fetch event listener
● Respond to requests for static assets using cache
self.addEventListener('fetch', function(event) {
event.respondWith(caches.open('devfestdc-static-v1').then(function(cache) {
cache.match(event.request).then(function(response) {
return response || fetch(event.request);
});
}));
});
YEAH! IT WORKED!
(BUT SHOULD WE DO IT?)
MANAGING CACHES
● Static assets (HTML/CSS/JSS) should be optimized for caching
● If we change “/schedule-day-2/”, we need to update the cache:
caches.open('devfestdc-static-v1')
● Hard to maintain
SW-PRECACHE
https://github.com/GoogleChrome/sw-precache
PRECACHE STATIC ASSETS
● sw-precache is a node module for generating a service worker that pre-caches
resources at build time
● Can be integrated into Gulp, Grunt, Webpack or CLI-based build scripts
● Install: npm install sw-precache --save-dev
PRECACHE STATIC ASSETS
● Run sw-precache at build time
● Gulp task outputs “/sw.js”:
gulp.task('generate-service-worker', function(callback) {
var swPrecache = require('sw-precache');
swPrecache.write('build/sw.js'), {
staticFileGlobs: [app/**/*.{js,html,css,png,jpg,gif,svg,eot,ttf,woff}']
}, callback);
});
THE WAY TO PWA
AN INCREMENTAL APPROACH
WEB APPLICATION MANIFEST
{
"name": "DevFestDC 2016",
"short_name": "DevFestDC",
"icons": [
...
{
"src": "launcher-icon-4x.png",
"sizes": "192x192",
"type": "image/png"
}
],
"start_url": "index.html",
"display": "standalone",
"orientation": "portrait"
}
<link rel="manifest" href="/manifest.json">
APP-SHELL ARCHITECTURE
● App shell is the minimal HTML, CSS, and JavaScript
required to render the user interface
● Its first load should be extremely quick, then
immediately cached (sw-precache)
SOURCE: https://www.devfestdc.rocks/
PRPL PATTERN
● Push critical resources for the initial route
● Render initial route (as fast as possible)
● Pre-cache remaining routes
● Lazy-load and create remaining routes on demand
SOURCE: https://www.polymer-project.org/1.0/toolbox/server
SW-TOOLBOX
https://github.com/GoogleChrome/sw-toolbox
RUN-TIME CACHING
● sw-toolbox provides handlers for common caching
patterns that are useful during run-time:
○ toolbox.cacheFirst
○ toolbox.networkFirst
○ toolbox.fastest
● sw-precache can configure and include sw-toolbox
SOURCE: https://github.com/GoogleChrome/sw-toolbox
LIGHTHOUSE
https://github.com/GoogleChrome/lighthouse
AUDIT PROGRESS
● lighthouse audits Progressive Web Apps
● Uses the Chrome Debugging Protocol
● Helps find problems during development
● Available from npm or as Chrome Extension
● github.com/GoogleChrome/lighthouse
PROGRESSIVE WEB APPS
● PWAs are still websites
● Progressively enhanced
● Connectivity independent
● Mobile-first & offline-first
● https://www.devfestdc.rocks/
● github.com/GoogleChrome/sw-toolbox
● github.com/GoogleChrome/sw-precache
● github.com/GoogleChrome/lighthouse
Chris Nguyen
@uncompiled

Contenu connexe

Tendances

Wso2 product release webinar introducing jaggery
Wso2 product release webinar   introducing jaggeryWso2 product release webinar   introducing jaggery
Wso2 product release webinar introducing jaggery
WSO2
 
Architecture & Workflow of Modern Web Apps
Architecture & Workflow of Modern Web AppsArchitecture & Workflow of Modern Web Apps
Architecture & Workflow of Modern Web Apps
Rasheed Waraich
 

Tendances (20)

Real World Progressive Web Apps (Building Flipkart Lite)
Real World Progressive Web Apps (Building Flipkart Lite)Real World Progressive Web Apps (Building Flipkart Lite)
Real World Progressive Web Apps (Building Flipkart Lite)
 
Progressive Web App
Progressive Web AppProgressive Web App
Progressive Web App
 
The web - What it has, what it lacks and where it must go - keynote at Riga D...
The web - What it has, what it lacks and where it must go - keynote at Riga D...The web - What it has, what it lacks and where it must go - keynote at Riga D...
The web - What it has, what it lacks and where it must go - keynote at Riga D...
 
Modern Web Applications Utilizing HTML5 (Dev Con TLV 06-2013)
Modern Web Applications Utilizing HTML5 (Dev Con TLV 06-2013)Modern Web Applications Utilizing HTML5 (Dev Con TLV 06-2013)
Modern Web Applications Utilizing HTML5 (Dev Con TLV 06-2013)
 
Progressive Web Apps are here!
Progressive Web Apps are here!Progressive Web Apps are here!
Progressive Web Apps are here!
 
Pwa.pptx
Pwa.pptxPwa.pptx
Pwa.pptx
 
Progressive Web Applications
Progressive Web ApplicationsProgressive Web Applications
Progressive Web Applications
 
Building a Progressive Web App
Building a  Progressive Web AppBuilding a  Progressive Web App
Building a Progressive Web App
 
Progressive web apps with Angular 2
Progressive web apps with Angular 2Progressive web apps with Angular 2
Progressive web apps with Angular 2
 
Introduction to Progressive Web App
Introduction to Progressive Web AppIntroduction to Progressive Web App
Introduction to Progressive Web App
 
Guidance on how to develop a progressive web app using react native!
Guidance on how to develop a progressive web app using react native!Guidance on how to develop a progressive web app using react native!
Guidance on how to develop a progressive web app using react native!
 
Wso2 product release webinar introducing jaggery
Wso2 product release webinar   introducing jaggeryWso2 product release webinar   introducing jaggery
Wso2 product release webinar introducing jaggery
 
Next Generation Mobile Web - PWA (Progressive Web App)
Next Generation Mobile Web  - PWA (Progressive Web App)Next Generation Mobile Web  - PWA (Progressive Web App)
Next Generation Mobile Web - PWA (Progressive Web App)
 
Architecture & Workflow of Modern Web Apps
Architecture & Workflow of Modern Web AppsArchitecture & Workflow of Modern Web Apps
Architecture & Workflow of Modern Web Apps
 
Progressive Web App
Progressive Web AppProgressive Web App
Progressive Web App
 
Progressive web app
Progressive web appProgressive web app
Progressive web app
 
Progressive Web Apps / GDG DevFest - Season 2016
Progressive Web Apps / GDG DevFest - Season 2016Progressive Web Apps / GDG DevFest - Season 2016
Progressive Web Apps / GDG DevFest - Season 2016
 
Pwa demystified
Pwa demystifiedPwa demystified
Pwa demystified
 
The Next Step in Responsive - RESS
The Next Step in Responsive - RESSThe Next Step in Responsive - RESS
The Next Step in Responsive - RESS
 
Django Deployer
Django DeployerDjango Deployer
Django Deployer
 

Similaire à The Hitchhiker's Guide to Building a Progressive Web App

Grunt, Gulp & fabs: Build Systems and Development-Workflow for Modern Web-App...
Grunt, Gulp & fabs: Build Systems and Development-Workflow for Modern Web-App...Grunt, Gulp & fabs: Build Systems and Development-Workflow for Modern Web-App...
Grunt, Gulp & fabs: Build Systems and Development-Workflow for Modern Web-App...
Philipp Burgmer
 

Similaire à The Hitchhiker's Guide to Building a Progressive Web App (20)

GDG Ibadan #pwa
GDG Ibadan #pwaGDG Ibadan #pwa
GDG Ibadan #pwa
 
GWT and PWA
GWT and PWAGWT and PWA
GWT and PWA
 
The MEAN stack - SoCalCodeCamp - june 29th 2014
The MEAN stack - SoCalCodeCamp - june 29th 2014The MEAN stack - SoCalCodeCamp - june 29th 2014
The MEAN stack - SoCalCodeCamp - june 29th 2014
 
Grunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous IntegrationGrunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous Integration
 
Grunt, Gulp & fabs: Build Systems and Development-Workflow for Modern Web-App...
Grunt, Gulp & fabs: Build Systems and Development-Workflow for Modern Web-App...Grunt, Gulp & fabs: Build Systems and Development-Workflow for Modern Web-App...
Grunt, Gulp & fabs: Build Systems and Development-Workflow for Modern Web-App...
 
Progressive Web Apps
Progressive Web AppsProgressive Web Apps
Progressive Web Apps
 
DevOps for Hackathons: DevOps without the Ops
DevOps for Hackathons: DevOps without the OpsDevOps for Hackathons: DevOps without the Ops
DevOps for Hackathons: DevOps without the Ops
 
PWA - Progressive Web App
PWA - Progressive Web AppPWA - Progressive Web App
PWA - Progressive Web App
 
WordCamp Atlanta - April 15 2018 - dev team workflow and processes with word...
WordCamp Atlanta -  April 15 2018 - dev team workflow and processes with word...WordCamp Atlanta -  April 15 2018 - dev team workflow and processes with word...
WordCamp Atlanta - April 15 2018 - dev team workflow and processes with word...
 
Service workers
Service workersService workers
Service workers
 
Progressive Web Apps
Progressive Web AppsProgressive Web Apps
Progressive Web Apps
 
Google Cloud Developer Challenge - GDG Belgaum
Google Cloud Developer Challenge - GDG BelgaumGoogle Cloud Developer Challenge - GDG Belgaum
Google Cloud Developer Challenge - GDG Belgaum
 
Java Web Start czyli jak żyć z tą dziwną technologią & Continuous Delivery w ...
Java Web Start czyli jak żyć z tą dziwną technologią & Continuous Delivery w ...Java Web Start czyli jak żyć z tą dziwną technologią & Continuous Delivery w ...
Java Web Start czyli jak żyć z tą dziwną technologią & Continuous Delivery w ...
 
Flutter for web
Flutter for webFlutter for web
Flutter for web
 
Progressive Web Apps - deep dive
Progressive Web Apps - deep diveProgressive Web Apps - deep dive
Progressive Web Apps - deep dive
 
WordPress on the Jamstack by rtCamper Muhammad Muhsin @ WordPress Colombo Meetup
WordPress on the Jamstack by rtCamper Muhammad Muhsin @ WordPress Colombo MeetupWordPress on the Jamstack by rtCamper Muhammad Muhsin @ WordPress Colombo Meetup
WordPress on the Jamstack by rtCamper Muhammad Muhsin @ WordPress Colombo Meetup
 
The web - What it has, what it lacks and where it must go - Bulgaria Web Summ...
The web - What it has, what it lacks and where it must go - Bulgaria Web Summ...The web - What it has, what it lacks and where it must go - Bulgaria Web Summ...
The web - What it has, what it lacks and where it must go - Bulgaria Web Summ...
 
ServiceWorker: New game changer is coming!
ServiceWorker: New game changer is coming!ServiceWorker: New game changer is coming!
ServiceWorker: New game changer is coming!
 
Progressive Web Apps - Overview & Getting Started
Progressive Web Apps - Overview & Getting StartedProgressive Web Apps - Overview & Getting Started
Progressive Web Apps - Overview & Getting Started
 
Building modern Progressive Web Apps with Polymer
Building modern Progressive Web Apps with PolymerBuilding modern Progressive Web Apps with Polymer
Building modern Progressive Web Apps with Polymer
 

Dernier

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Dernier (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 

The Hitchhiker's Guide to Building a Progressive Web App

  • 1. THE HITCHHIKER’S GUIDE TO BUILDING A PROGRESSIVE WEB APP Chris Nguyen @uncompiled
  • 2.
  • 5.
  • 6. PROGRESSIVE WEB APPS ● Progressive ● Responsive ● Linkable ● Fresh ● App-like ● Safe ● Discoverable ● Installable ● Re-engageable ● Connectivity independent SOURCE: https://developers.google.com/web/fundamentals/getting-started/your-first-progressive-web-app/
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14. PROGRESSIVE WEB APPS ✓ Progressive ● Responsive ● Linkable ● Fresh ● App-like ● Safe ● Discoverable ● Installable ● Re-engageable ● Connectivity independent SOURCE: https://developers.google.com/web/fundamentals/getting-started/your-first-progressive-web-app/
  • 16.
  • 17. PROGRESSIVE WEB APPS ✓ Progressive ✓ Responsive ● Linkable ● Fresh ● App-like ● Safe ● Discoverable ● Installable ● Re-engageable ● Connectivity independent SOURCE: https://developers.google.com/web/fundamentals/getting-started/your-first-progressive-web-app/
  • 19. @slightlylate: "URLs are the web's superpower." #chromedevsummit
  • 20. PROGRESSIVE WEB APPS ✓ Progressive ✓ Responsive ✓ Linkable ● Fresh ● App-like ● Safe ● Discoverable ● Installable ● Re-engageable ● Connectivity independent SOURCE: https://developers.google.com/web/fundamentals/getting-started/your-first-progressive-web-app/
  • 23. PROGRESSIVE WEB APPS ✓ Progressive ✓ Responsive ✓ Linkable ✓ Fresh ● App-like ● Safe ● Discoverable ● Installable ● Re-engageable ● Connectivity independent SOURCE: https://developers.google.com/web/fundamentals/getting-started/your-first-progressive-web-app/
  • 25. APP-LIKE ● Familiar interface ● Fast screen transitions ● Smooth scrolling ● Feels native SOURCE: https://app.ft.com
  • 26.
  • 27.
  • 28. PROGRESSIVE WEB APPS ✓ Progressive ✓ Responsive ✓ Linkable ✓ Fresh ✓ App-like ● Safe ● Discoverable ● Installable ● Re-engageable ● Connectivity independent SOURCE: https://developers.google.com/web/fundamentals/getting-started/your-first-progressive-web-app/
  • 29. SAFE
  • 30. SAFE ● Must be served using HTTPS ● Prevents snooping or MITM attacks ● Privacy and security for users
  • 31.
  • 32. White House OMB Memorandum 15-13 SOURCE: https://https.cio.gov
  • 33. White House OMB Memorandum 15-13 SOURCE: https://https.cio.gov
  • 34. PROGRESSIVE WEB APPS ✓ Progressive ✓ Responsive ✓ Linkable ✓ Fresh ✓ App-like ✓ Safe ● Discoverable ● Installable ● Re-engageable ● Connectivity independent SOURCE: https://developers.google.com/web/fundamentals/getting-started/your-first-progressive-web-app/
  • 36. WEB APPLICATION MANIFEST { "name": "My Web Application", "short_name": "My App", "description": "A Simple Progressive Web App", "icons": [ ... { "src": "launcher-icon-4x.png", "sizes": "192x192", "type": "image/png" } ], "start_url": "/index.html", "display": "standalone", "orientation": "portrait" } <link rel="manifest" href="/manifest.json">
  • 37. PROGRESSIVE WEB APPS ✓ Progressive ✓ Responsive ✓ Linkable ✓ Fresh ✓ App-like ✓ Safe ✓ Discoverable ● Installable ● Re-engageable ● Connectivity independent SOURCE: https://developers.google.com/web/fundamentals/getting-started/your-first-progressive-web-app/
  • 39. INSTALLABLE ● Multiple visits trigger prompt ● Low friction ● No app store SOURCE: https://www.devfestdc.rocks
  • 40. PROGRESSIVE WEB APPS ✓ Progressive ✓ Responsive ✓ Linkable ✓ Fresh ✓ App-like ✓ Safe ✓ Discoverable ✓ Installable ● Re-engageable ● Connectivity independent SOURCE: https://developers.google.com/web/fundamentals/getting-started/your-first-progressive-web-app/
  • 42.
  • 44. PROGRESSIVE WEB APPS ✓ Progressive ✓ Responsive ✓ Linkable ✓ Fresh ✓ App-like ✓ Safe ✓ Discoverable ✓ Installable ✓ Re-engageable ● Connectivity independent SOURCE: https://developers.google.com/web/fundamentals/getting-started/your-first-progressive-web-app/
  • 46.
  • 47. MOBILE NETWORKS ARE UNRELIABLE ● LTE service isn’t always LTE ● Mobile devices constantly transfer between antennas, 3G, LTE, and Wi-Fi ● Slow response is worse than fast connection failure SOURCE: https://hpbn.co
  • 48.
  • 49. LATENCY: THE NEW WEB PERFORMANCE BOTTLENECK SOURCE: https://www.igvita.com/2012/07/19/latency-the-new-web-performance-bottleneck/
  • 50. MOBILE-FIRST WEB DEVELOPMENT ● Responsive Web Design ○ Addresses the mobile user interface ● Service Worker API ○ Addresses the mobile network ● Design for slow mobile devices and slow networks ○ It’ll be ⚡ on high-end phones and fast networks
  • 52.
  • 53.
  • 54.
  • 55. SERVICE WORKER ● Client-side programmable network proxy ● Registered against a domain & path ○ www.devfestdc.org != images.devfestdc.org ○ www.devfestdc.org != www.devfestdc.org/js ● Intercept network requests ● Gives developers control of network failure
  • 56. OFFLINE SUPPORT (USING A SERVICE WORKER)
  • 57.
  • 58.
  • 59. DEVFESTDC.ORG: INSTALL SERVICE WORKER ● Register a service worker for www.devfestdc.org ● Install at root scope (“/”) so it can handle the entire site if('serviceWorker' in navigator) { navigator.serviceWorker .register('/sw.js') .then(function() { console.log('Service Worker Registered'); }); }
  • 60. DEVFESTDC.ORG: CACHE ASSETS ● Inside “/sw.js”, cache all the assets ● Include all HTML, CSS, and JS required to load the site self.addEventListener('install', function(event) { event.waitUntil( caches.open('devfestdc-static-v1').then(function(cache) { return cache.addAll(['/index.html', '/js/all.min.js', ... /* etc */ ]); }); ); });
  • 61. DEVFESTDC.ORG: RESPOND WITH CACHED ASSETS ● Inside “/sw.js”, add fetch event listener ● Respond to requests for static assets using cache self.addEventListener('fetch', function(event) { event.respondWith(caches.open('devfestdc-static-v1').then(function(cache) { cache.match(event.request).then(function(response) { return response || fetch(event.request); }); })); });
  • 62.
  • 63. YEAH! IT WORKED! (BUT SHOULD WE DO IT?)
  • 64. MANAGING CACHES ● Static assets (HTML/CSS/JSS) should be optimized for caching ● If we change “/schedule-day-2/”, we need to update the cache: caches.open('devfestdc-static-v1') ● Hard to maintain
  • 66.
  • 67. PRECACHE STATIC ASSETS ● sw-precache is a node module for generating a service worker that pre-caches resources at build time ● Can be integrated into Gulp, Grunt, Webpack or CLI-based build scripts ● Install: npm install sw-precache --save-dev
  • 68. PRECACHE STATIC ASSETS ● Run sw-precache at build time ● Gulp task outputs “/sw.js”: gulp.task('generate-service-worker', function(callback) { var swPrecache = require('sw-precache'); swPrecache.write('build/sw.js'), { staticFileGlobs: [app/**/*.{js,html,css,png,jpg,gif,svg,eot,ttf,woff}'] }, callback); });
  • 69. THE WAY TO PWA AN INCREMENTAL APPROACH
  • 70. WEB APPLICATION MANIFEST { "name": "DevFestDC 2016", "short_name": "DevFestDC", "icons": [ ... { "src": "launcher-icon-4x.png", "sizes": "192x192", "type": "image/png" } ], "start_url": "index.html", "display": "standalone", "orientation": "portrait" } <link rel="manifest" href="/manifest.json">
  • 71. APP-SHELL ARCHITECTURE ● App shell is the minimal HTML, CSS, and JavaScript required to render the user interface ● Its first load should be extremely quick, then immediately cached (sw-precache) SOURCE: https://www.devfestdc.rocks/
  • 72. PRPL PATTERN ● Push critical resources for the initial route ● Render initial route (as fast as possible) ● Pre-cache remaining routes ● Lazy-load and create remaining routes on demand SOURCE: https://www.polymer-project.org/1.0/toolbox/server
  • 74. RUN-TIME CACHING ● sw-toolbox provides handlers for common caching patterns that are useful during run-time: ○ toolbox.cacheFirst ○ toolbox.networkFirst ○ toolbox.fastest ● sw-precache can configure and include sw-toolbox SOURCE: https://github.com/GoogleChrome/sw-toolbox
  • 76. AUDIT PROGRESS ● lighthouse audits Progressive Web Apps ● Uses the Chrome Debugging Protocol ● Helps find problems during development ● Available from npm or as Chrome Extension ● github.com/GoogleChrome/lighthouse
  • 77.
  • 78.
  • 79. PROGRESSIVE WEB APPS ● PWAs are still websites ● Progressively enhanced ● Connectivity independent ● Mobile-first & offline-first ● https://www.devfestdc.rocks/ ● github.com/GoogleChrome/sw-toolbox ● github.com/GoogleChrome/sw-precache ● github.com/GoogleChrome/lighthouse Chris Nguyen @uncompiled