Progressive Web Apps: Native for the web!

7e6b46c3ed5205fe1ce4f47425fd267e?s=47 Steffen Jahr
September 05, 2017

Progressive Web Apps: Native for the web!

The term Progressive Web Apps (PWA) was defined by Google in 2015. It describes the technologies you can use to develop a new type of web applications. Push notifications, offline possibilities and installable apps are only a few of the application's properties. But there is more...

Steffen Jahr from Thinktecture wants you to show how a PWA can look like and which technologies you can use. He will show you the upcoming technologies and which browser support that cutting edge technologies. And all this is done with pure HTML, CSS and JavaScript

7e6b46c3ed5205fe1ce4f47425fd267e?s=128

Steffen Jahr

September 05, 2017
Tweet

Transcript

  1. 1.
  2. 2.

    RheinNeckarJS Progressive Web Apps: Native for the web! Who is

    speaking? Steffen Jahr Software Developer @ Thinktecture AG ! steffen.jahr@thinktecture.com " @steffenjahr # https://steffenjahr.de
  3. 3.

    • Native development • One programming language per platform •

    Android: Java • iOS: Objective-C • Windows Phone: C# Progressive Web Apps: Native for the web! RheinNeckarJS App development at the beginning (Source: https://www.ifixit.com/Device/iPhone_1st_Generation)
  4. 4.

    • Cross Platform Development • HTML5, JavaScript & CSS3 •

    Write once, run anywhere! Progressive Web Apps: Native for the web! RheinNeckarJS App development today (Source: http://view.ionic.io/phones.png)
  5. 6.

    • 669k Apps in Windows Store (phones and tablets included)

    • 29k Apps in Mac App Store • Native development • C# • Swift • Objective-C • Electron app • HTML5 • CCS3 • JavaScript Progressive Web Apps: Native for the web! RheinNeckarJS What about desktop?
  6. 7.

    • No difference between website or app • Apps can

    be installed directly from browser • One programming language for all platforms • Access to native device resources Progressive Web Apps: Native for the web! RheinNeckarJS What about the future?
  7. 8.

    The answer! • Defined by Google in 2015 • No

    new technology to develop applications • No new programming language needed • Describes a type of applications • Installable • Offline • Push Notifications • And much more… Progressive Web Apps: Native for the web! RheinNeckarJS Progressive Web Apps
  8. 9.

    Properties Progressive Web Apps: Native for the web! RheinNeckarJS Progressive

    Web Apps Safe Progressive Responsive Discoverable App-like Fresh Connectivity Independent Re- engageable Installable Linkable
  9. 10.

    A real world application • Twitter Lite (introduced April 2017)

    • Push Notifications • Responsive • Offline • Safe • Automatic Updates • https://lite.twitter.com/ Progressive Web Apps: Native for the web! RheinNeckarJS Progressive Web Apps (Source: https://lite.twitter.com/)
  10. 11.

    Let’s build a foundation • Frame of the application •

    Cached • Fast loading time • Content is loaded dynamically • Minimal HTML, CSS and JavaScript Progressive Web Apps: Native for the web! RheinNeckarJS App-Shell (Source: https://developers.google.com/web/updates/2015/11/app-shell)
  11. 12.

    • Single Page Applications = SPA • Only one page

    that is loaded only once • Content is replaced dynamically • No reload on links • Famous frameworks: • Angular • React • Vue.js Progressive Web Apps: Native for the web! RheinNeckarJS Excursion: Single-Page Applications
  12. 13.

    • Lives in its own JavaScript file • Has its

    own thread to prevent UI blocking • Background tasks • No DOM manipulation • Can communicate with the application • Send messages with postMessage() • Proxy between app and network • Have to be installed • Available: https://jakearchibald.github.io/isserviceworkerready/ Progressive Web Apps: Native for the web! RheinNeckarJS Service Worker
  13. 15.

    Lifecycle Progressive Web Apps: Native for the web! RheinNeckarJS Service

    Worker Installing Parsed Error Activated Idle Terminated fetch/ message
  14. 16.

    Security first! • Progressive Web Apps require HTTPS • Only

    localhost is allowed for development • Security is very important because of Service Worker power • Service Worker can affect the application • Service Worker has access to network traffic Progressive Web Apps: Native for the web! RheinNeckarJS Safe
  15. 17.

    • Developing gradually • Features depending on browser support •

    Check for feature support: https://caniuse.com • Browser with the best support: Google Chrome • No Service Worker support (yet): Internet Explorer, Edge, Safari Progressive Web Apps: Native for the web! RheinNeckarJS Progressive
  16. 18.

    • One layout for all devices • Phone • Tablet

    • Desktop • Layout reacts on resizing • Implementation with CSS3 Media Queries or CSS frameworks (that use Media Queries) • Media Queries: https://github.com/eduardoboucas/include-media • Bootstrap • Foundation • Material Progressive Web Apps: Native for the web! RheinNeckarJS Responsive
  17. 19.

    • How to differ between a website and a Progressive

    Web App • Idea: Define Metadata for the application • Solution: Manifest.json • Requirement for more Progressive Web App features • Linked in index.html • Search machines can differ between website and app Progressive Web Apps: Native for the web! RheinNeckarJS Discoverable
  18. 20.

    • Usage of native APIs • Audio • Camera •

    Storage • Location • No reload on site navigation • Usage of app shell • Fast loading time • Dynamic content • Development: Mobile first Progressive Web Apps: Native for the web! RheinNeckarJS App-Like
  19. 21.

    • Service Worker is always up-to-date • Caches will be

    refreshed during update • Respects max-age of the Service Worker script • Service Worker will be reloaded every 24h at least Progressive Web Apps: Native for the web! RheinNeckarJS Fresh
  20. 22.

    • App is available offline • Difference between app and

    data • App can be cached in Cache Storage through Service Worker • Data should be cached in a local storage (LocalStorage, IndexedDB) Progressive Web Apps: Native for the web! RheinNeckarJS Connectivity Independent
  21. 23.

    Offline strategies • Cache only • Network only • Cache,

    falling back to network • Cache & network race • Network falling back to cache • Cache then network • Generic fallback • https://jakearchibald.com/2014/offline-cookbook/ Progressive Web Apps: Native for the web! RheinNeckarJS Connectivity Independent
  22. 24.

    Progressive Web Apps: Native for the web! RheinNeckarJS Connectivity independent

    App Cache Storage Database Server Internet fetch HTTP Service Worker
  23. 25.

    Fetch-API • No usage of XMLHttpRequest • Fetch API is

    more powerful • Usage of Cache API • Promise based • Streaming responses • Abort requests • Report progress • Helps Service Worker to act as proxy between app and network • Service Worker uses API to respond network requests from cache Progressive Web Apps: Native for the web! RheinNeckarJS Connectivity Independent
  24. 26.

    Browser storage • Used to store app data • Different

    types • Local Storage (only few MB) • Only key – value • Service Worker has no access to Local Storage • IndexedDB (depends on browser) • More powerful then Local Storage • Provides indexes • Has own query language • Supports transactions Progressive Web Apps: Native for the web! RheinNeckarJS Connectivity Independent
  25. 27.

    Data Sync • How is data synced with the server?

    • Sync in the app • Sync on interval • Sync on action • Sync within the app can crash the application Progressive Web Apps: Native for the web! RheinNeckarJS Connectivity Independent
  26. 28.

    The Progressive Web App way to sync data • Use

    of Sync API • Available in Service Worker • Syncs data in Service Worker instead of the application • Two types of sync: • Sync • Periodic sync • Periodic sync is not implemented yet • Sync API is only implemented in Google Chrome Progressive Web Apps: Native for the web! RheinNeckarJS Connectivity Independent
  27. 29.

    Please come back • Bring back users to the application

    • Progressive Web Apps can use notifications • Look like native app notifications • Also notifications on desktop • App needs authorization for notifications Progressive Web Apps: Native for the web! RheinNeckarJS Re-engageable
  28. 30.

    Push API • Service Worker can receive push data from

    the server • Supported by: • Google Chrome • Mozillla Firefox • Every Browser has its own Push Service • Chrome: Firebase Cloud Messaging • Firefox: Mozilla Push Service • Push messages only can be received from this Push services (yet) Progressive Web Apps: Native for the web! RheinNeckarJS Re-engageable
  29. 31.

    • Installable without App Store • Browser shows banner to

    install • Needs information in Manifest.json • Icon (144x144) • Name • User has visited site at least twice, with at least five minutes between visits • Installable depends on Service Worker Progressive Web Apps: Native for the web! RheinNeckarJS Installable
  30. 32.

    • App is linkable because it is a web application

    • State of the application is controlled by URL • https://pwa-wishlist.herokuapp.com/#/features • Very complex to implement in conventional desktop applications Progressive Web Apps: Native for the web! RheinNeckarJS Linkable
  31. 33.

    • Web Share API • Share data with other applications

    • Only available in Chrome Beta for Android • Web Share Target API • Make your application a share target • Payment Request API • Start payment request • Only available in Edge and Chrome for Android • Web Bluetooth API • Interact with bluetooth devices • Only available in Chrome Progressive Web Apps: Native for the web! RheinNeckarJS More APIs
  32. 34.

    Workbox § Provides common caching strategies § Also provides offline

    analytics (based on Google Analytics) § Available for different build tools § https://workboxjs.org/ Progressive Web Apps: Native for the web! RheinNeckarJS Tools
  33. 35.

    Lighthouse • Tool from Google • Chrome-Extension or Node module

    • Checks different indicators if your app works like a Progressive Web App • Service Worker • Performance • App-Like • HTTPS Progressive Web Apps: Native for the web! RheinNeckarJS Tools
  34. 36.

    • Progressive Web Apps can be the future • Depends

    on support of browser companies • Apple has just started to implement the Service Worker • Payment has to be solved • No App Stores === No payment • Payment Request API can be the right way • Google and Microsoft are pushing hard! • New APIs are coming Progressive Web Apps: Native for the web! RheinNeckarJS A glance across the border
  35. 37.

    • Livin’ On The Edge • Browser support is not

    optimal • Great way to extend current applications • Progressive Web Apps can be built for Android devices • Apple is forced to act because of Androids overwhelming market share Progressive Web Apps: Native for the web! RheinNeckarJS Summary