Software:Progressive Web Apps

From HandWiki

Progressive Web Apps (PWAs) are web applications that load like regular web pages or websites but can offer the user functionality such as working offline, push notifications, and device hardware access traditionally available only to native mobile applications. PWAs are an emerging technology that combine the open standards of the web offered by modern browsers to provide benefits of a rich mobile experience.

Background

Since around 2005 web development technologies have shifted from static to dynamic documents driven by server (PHP, ASP.NET) client side (e.g. Ajax[1]) tools, and responsive web design.[2] Despite an early push for web-based apps based on these technologies on devices such as the 2007 iPhone, attempts at web apps failed by comparison to native apps. Native apps provided a better user experience and booted faster compared to having to load in a browser at runtime. Packaged resources and direct access to hardware allowed native apps to perform much faster to provide more features. By mid 2010, however, continued enhancements in HTML5, CSS3, and JavaScript, significantly more capable and standards compliant web browsers, along with powerful processors such as the A10 and Snapdragon 821 made performant hybrid-apps a viable alternative.

Characteristics

In 2015, designer Frances Berriman and Google Chrome engineer Alex Russell coined the term "progressive web apps"[3] to describe apps taking advantage of new features supported by modern browsers, including service workers and web app manifests, that let users upgrade web apps to progressive web applications in their native operating system (OS). According to Google Developers,[3][4][5] these characteristics are:

  • Progressive - Work for every user, regardless of browser choice because they’re built with progressive enhancement as a core tenet.
  • Responsive - Fit any form factor: desktop, mobile, tablet, or forms yet to emerge.
  • Connectivity independent - Service workers allow work offline, or on low quality networks.
  • App-like - Feel like an app to the user with app-style interactions and navigation.
  • Fresh - Always up-to-date thanks to the service worker update process.
  • Safe - Served via HTTPS to prevent snooping and ensure content hasn’t been tampered with.
  • Discoverable - Are identifiable as “applications” thanks to W3C manifests[6] and service worker registration scope allowing search engines to find them.
  • Re-engageable - Make re-engagement easy through features like push notifications.
  • Installable - Allow users to “keep” apps they find most useful on their home screen without the hassle of an app store.
  • Linkable - Easily shared via a URL and do not require complex installation.

Progressive web apps are an enhancement of existing web technology. As such, they do not require separate bundling or distribution. Publication of a progressive web app is as it would be for any other web page. PWAs **work** in any browser, but "app-like" features such as being independent of connectivity, install to home screen & push messaging depend on browser support. As of April 2018, those features are supported to varying degrees by the Microsoft Edge, Google Chrome, Mozilla Firefox and Safari browsers, but more browsers may support the features needed in the future.[7][8]

The technical baseline criteria for a site to be considered a progressive web app by browsers were described by Russell in a follow-up post:[9]

  • Originate from a secure origin. Served over TLS and green padlock displays (no active mixed content).
  • Load while offline (even if only a custom offline page). By implication, this means that progressive web apps require service workers.
  • Reference a web app manifest with at least the four key properties: name, short_name, start_url, and display (with a value of standalone or fullscreen)
  • An icon at least 144×144 large in png format. E.g.: "icons": [ { "src": "/images/icon-144.png", "sizes": "144x144", "type": "image/png" } ]

Technologies

Commonly used technologies serve to create progressive web apps in the broad sense[10][11][12] are the following:

Manifest

The web app manifest is a W3C specification defining a JSON-based manifest[6] to provide developers a centralized place to put metadata associated with a web application including:

  • The name of the web application
  • Links to the web app icons or image objects
  • The preferred URL to launch or open the web app
  • The web app configuration data for a number of characteristics
  • Declaration for default orientation of the web app
  • Enables to set the display mode e.g. full screen

This metadata is crucial for an app to be added to a home screen or otherwise listed alongside native apps.

AppCache (obsolete)

An earlier technology to support offline use of the web. [13] It works adequately for the use case it was designed for (single-page application), but fails in problematic ways for wikis and other multi-page apps.[14] Currently supported by major browsers and in use for years by some sites, but will eventually be removed.

Service workers

Native mobile apps deliver rich experiences and high performance, purchased at the expense of storage space, lack of real-time updates, and low search engine visibility. Traditional web apps suffer from the inverse set of factors: lack of a native compiled executable, along with dependence on unreliable and potentially slow web connectivity. Service workers are used in an attempt to give progressive web apps the best of both these worlds.[15]

Technically, service workers provide a scriptable network proxy in the web browser to manage the web/HTTP requests programmatically. The service workers lie between the network and device to supply the content. They are capable of using the cache mechanisms efficiently and allow error-free behavior during offline periods.

Properties of service workers:

  1. Trigger and keep alive by the relationship to the events, not by the documents.
  2. Generic in nature
  3. Event-driven with time limit scripting contexts and running at the origin
  4. With natural endpoints for a wide range of runtime services
  5. Have a state
  6. With a script URL
  7. Containing registration
  8. Allocated ID or UUID
  9. With lifecycle events
  10. Have script resource map
  11. Can skip waiting for the flags

Benefits of service workers:

  • Capable of handling the push notification easily
  • Synchronise data in the background
  • Capable of responding to resource requests originating elsewhere
  • Receive centralized updates

WebWorkers

Allows a web app to run multiple threads of (JavaScript) code simultaneously[16] Thus, long activities can be moved off the user-interface thread, keeping responses snappy. They have a close relationship with Service Workers, but are more widely supported.

WebAssembly

Allows precompiled code to run in a web browser, at near-native speed. [17] Thus, libraries written in languages such as C can be added to web apps. Due to the cost of passing data from JavaScript to WebAssembly, near-term uses will be mainly number-crunching (such as voice recognition and computer vision), rather than whole applications.

Indexed Database (IDB)

A NoSQL database built into modern browsers[18] Allows a PWA to immediately display content, regardless of connection status or speed.

LocalStorage & SessionStorage

Key-Value stores that largely make cookies obsolete.[19]

Application shell architecture

Some progressive web apps use an architectural approach called the App Shell Model.[20] For rapid loading, service workers store the Basic User Interface or "shell" of the responsive web design web application. This shell provides an initial static frame, a layout or architecture into which content can be loaded progressively as well as dynamically, allowing users to engage with the app despite varying degrees of web connectivity. The shell can be stored locally in the browser cache of the mobile device.[21]

Directories and examples

  • PWA Directory is a moderated list that allows searching by keyword or Lighthouse score[22].
  • The Microsoft Store contains "PWAs" packaged for Windows 10, but does not appear to contain links to actual on-line PWAs. It's not clear that it can list web apps separate from Windows apps.

The following list includes progressive web apps together with their scores from Google Chrome's PWA audit powered by Lighthouse.[22] The audit validates the aspects of a PWA, as specified by Google's baseline PWA Checklist and ranges from 0 (worst) to 100 (best).

List of PWAs
Name Description Link Audit score
ReSTbasis Web Starter Kit. [1] 100
The Air Horner An Air horn. [2] 100
chromestatus Chrome Platform Status [3] 100
Serene Notes text & picture notes, retrievable by context [4] 100
Dev.Opera Web features and implementations [5] 73
Appscope Directory of PWAs [6] 100
Bet Calculator Online bet calculator [7] 91
emojoy [8] 82
Expense Manager Example expense manager [9]
Firefox Platform Status Roadmap for web platform features [10]
Flipkart Lite Online shopping [11] 55
GitHub Explorer [12]
Google I/O [13] 82
Guitar Tuner Tune a guitar [14] 82
Instant Website Maker Make A Website [15] 100
Kite OnAir network Kite Network [16]
koolsol solitaire card game [17] 100
Memory Game PWA [18] 91
MotoPlaces Biker App [19] 73
Notepad Offline Notes [20]
Paytm Lite [21] 91
Pokedex [22] 91
Polymon by Polymer [23]
Progressive Beer [24] 82
Progressive Web App.Store A PWA Store [25] 100
QR Code Scanner Offline QR code scanner [26] 100
React HN [27]
Remember GPS logging [28] 73
Resume Nation [29] 91
SVGOMG SVG editor [30] 82
Smaller Pictures [31]
Soundslice [32] 64
SplittyPie [33]
sv-ginger WebGL Morph Demo [34] 91
SuperPWA PWA Software [35] 100
Taskade [36]
TeamGrid [37]
Twitter [38] 82
Uber [39] 82
voice-memos [40]
Washington Post [41] 55
Wave-PD1 Synthesizer with Web Audio API [42] 73
Web Bluetooth (Intel® Edison demo) [43] 100
Web NFC enabled shopping cart [44] 100
Wiki Offline [45] 73
X Sound [46] 45

The following apps are or were claimed to be PWAs but fail to register an obligatory service worker:

Broken progressive web apps
Name Link Audit score
abc.xyz [47] 55
AMP project [48] 64
DevSpace [49] 55
Housing [50] 64
Medium [51] 55
Topple Trump! [52] 45
Web Bluetooth (Intel® Edison demo) [53] 100

References

  1. Garrett, Jesse James. "Ajax: A New Approach to Web Applications". Archived on January 29, 2016. Error: If you specify |archivedate=, you must also specify |archiveurl=. http://adaptivepath.org/ideas/ajax-new-approach-web-applications/. Retrieved February 18, 2005. 
  2. Marcotte, Ethan. "Responsive Web Design". Archived on January 29, 2016. Error: If you specify |archivedate=, you must also specify |archiveurl=. http://alistapart.com/article/responsive-web-design. Retrieved May 25, 2010. 
  3. 3.0 3.1 Russell, Alex. "Progressive Web Apps: Escaping Tabs Without Losing Our Soul". Archived on January 29, 2016. Error: If you specify |archivedate=, you must also specify |archiveurl=. https://infrequently.org/2015/06/progressive-apps-escaping-tabs-without-losing-our-soul/. Retrieved June 15, 2015. 
  4. "Your First Progressive Web App | Web Fundamentals - Google Developers". https://developers.google.com/web/fundamentals/getting-started/your-first-progressive-web-app/?hl=en. 
  5. Google Developers. "Progressive Web App". Archived on January 29, 2016. Error: If you specify |archivedate=, you must also specify |archiveurl=. https://developers.google.com/web/progressive-web-apps. Retrieved June 15, 2015. 
  6. 6.0 6.1 W3C “Web App Manifest”, Working Draft, retrieved 12 September 2016
  7. "Error: no |title= specified when using {{Cite web}}". https://caniuse.com/#search=pwa. Retrieved 14 August 2018. 
  8. "Is Service Worker Ready?". Jake Archibald. https://jakearchibald.github.io/isserviceworkerready/. 
  9. Russell, Alex. "What, Exactly, Makes a Progressive Web App". https://infrequently.org/2016/09/what-exactly-makes-something-a-progressive-web-app/. Retrieved October 18, 2016. 
  10. "Discoverable" (in en-US). https://developer.mozilla.org/en-US/Apps/Progressive/Discoverable. 
  11. "Network independent" (in en-US). https://developer.mozilla.org/en-US/Apps/Progressive/Network_independent. 
  12. "Instant Loading Web Apps with an Application Shell Architecture" (in en). https://developers.google.com/web/updates/2015/11/app-shell. 
  13. "Using the application cache". Mozilla. https://developer.mozilla.org/en-US/docs/Web/HTML/Using_the_application_cache. Retrieved 14 August 2018. 
  14. "Application Cache is a Douchebag". https://alistapart.com/article/application-cache-is-a-douchebag. Retrieved 14 August 2018. 
  15. "Learn Everything About Progressive Web Apps". http://www.htmlpanda.com/blog/learn-everything-about-progressive-web-apps/. 
  16. "Worker". https://developer.mozilla.org/en-US/docs/Web/API/Worker. Retrieved 14 August 2018. 
  17. "WebAssembly Concepts". https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts. Retrieved 14 August 2018. 
  18. "Concepts behind IndexedDB". https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API/Basic_Concepts_Behind_IndexedDB. Retrieved 14 August 2018. 
  19. "Web Storage API". https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API. Retrieved 14 August 2018. 
  20. "The App Shell Model". https://developers.google.com/web/fundamentals/architecture/app-shell. 
  21. "Progressive Web Apps – a Quality Mix of Web and Mobile". https://indylogix.com/progressive-web-apps/. 
  22. 22.0 22.1 "Lighthouse - Google Developers". https://developers.google.com/web/tools/lighthouse/.