{"id":9260,"date":"2020-05-29T22:00:02","date_gmt":"2020-05-29T21:00:02","guid":{"rendered":"https:\/\/exmachina.ch\/?p=9260"},"modified":"2023-06-28T19:19:44","modified_gmt":"2023-06-28T18:19:44","slug":"pwa-what","status":"publish","type":"post","link":"https:\/\/exmachina.ch\/en\/tech\/pwa-what\/","title":{"rendered":"PWA what?"},"content":{"rendered":"\r\n<p>To hype or not to hype? That is the question.<\/p>\r\n<p>PWA (as in <strong>P<\/strong>ossible <strong>W<\/strong>ayout from <strong>A<\/strong>pps) are a huge hype, for sure. But&#8230;<\/p>\r\n<p>&#8230;is now the right time to adopt a technology stack that will last no more than one or two years? Does it make sense to invest time and money learning dedicated and platform-specific knowledge in order to develop native applications (unless your app requires specific features or performance expectations)?<\/p>\r\n<p><strong><em>&#8220;You are too concerned with what was and what will be.&#8221; <\/em><\/strong>(Oogway &#8211; Kung Fu Panda)<\/p>\r\n<p>Believe it or not, pandas are still there. This time, however, they are following their own way of Kung Fu, and quoting Google <i>they are finally taking the right vitamins<\/i> (oh! I forgot to say that by \u201cpandas\u201d I really mean the good old web pages, and the very browser you are staring at).<\/p>\r\n<p>Simply put: what about adopting existing and emerging web application patterns to save time and money while delivering nonetheless quality services and apps?<\/p>\r\n<p>That is, basically, a\u00a0<strong><b>P<\/b><\/strong>rogressive\u00a0<strong><b>W<\/b><\/strong>eb\u00a0<strong><b>A<\/b><\/strong>pp: a future-proof bridge between traditional native apps and web applications.<\/p>\r\n<p><em><strong>&#8220;Fascinating!&#8221; <\/strong><\/em>(Mr. Spock)<\/p>\r\n<p>Ok, let\u2019s get serious. Turtles, pandas, and Star Trek characters sit down there in silence (for a while).<\/p>\r\n<h3>Progressive Web Apps: a new hope<\/h3>\r\n<p>Disclaimer: technical jargon following.<\/p>\r\n<p>PWAs are, at their core, nothing but<em> responsive websites <\/em><em>on steroids<\/em>. Websites that can progressively enhance their features depending on the browser\u2019s capabilities. It\u2019s all about making the most out of the last improvements in web browsers to create a better user experience. A web app which can leverage the edge of available technologies, to deliver a native app like experience on a mobile device.<\/p>\r\n<p>No magic or esoteric technologies here, apart a few experimental javascript API. Technically speaking a PWA simply is:<\/p>\r\n<p>1- any web site\/application served through <em>HTTPS<br \/><\/em>2- with a valid <em>app manifest<\/em>, and<br \/>3- a registered <em>service worker<\/em> which implements a fetch event handler (with a minimum support for caching\/offline)<\/p>\r\n<p>Now, since a progressive web app is nothing but a web application, there is no need for developers to distribute a PWA via proprietary repositories such as iTunes or Google Play. This is certainly a win-win for you and your users. In fact, no one is looking for your app on a store unless you are Facebook or Google Maps. Also, your users do not have to install yet another beefy app on their device: they will simply navigate to your webapp using their browser (with the option of an icon on the home screen \u2013 more on that later).<\/p>\r\n<p>Sure, to develop a good and working PWA requires a lot of know-how. The reward though is that you are able to deliver an accessible, platform independent, no-install, no-updates, engaging app which your users are happier with. Luckily, publishing and promoting a PWA is as it is for any other web page I.e. a good SEO to target traffic to your app.<\/p>\r\n<p>Intrigued?\u00a0<\/p>\r\n<p><em><strong>&#8220;Curiosity is the essence of our existence.&#8221; <\/strong><\/em>(Gene Cernan)\u00a0<\/p>\r\n<h3>Wait, but&#8230; why?<\/h3>\r\n<p>Following Google&#8217;s advice, we can sum up an app in terms of\u00a0<em>capabilities\u00a0<\/em>and\u00a0<em>reach<\/em>.<\/p>\r\n<p>Capability is at its best in native apps: they are fast, reliable, easily accessible from the home screen, and get full access to the device hardware. On the contrary, websites are ubiquitous, searchable, not controlled by a single private company, always up-to-date (no need to download or update from a store), and widely accessible by anyone anywhere.<\/p>\r\n<p>PWAs sit at the intersection of the best features of both worlds:<\/p>\r\n<p><a href=\"https:\/\/exmachina.ch\/images\/2020\/05\/diagram.png\"><img fetchpriority=\"high\" decoding=\"async\" src=\"https:\/\/exmachina.ch\/images\/2020\/05\/diagram-300x226.png\" alt=\"\" width=\"300\" height=\"226\" title=\"\"><\/a><\/p>\r\n<p>Too good to be true? Kind of\u2026 Let\u2019s recall the points listed in the previous section, and see how all that is possible.<\/p>\r\n<h3>HTTPS<\/h3>\r\n<p>HTTPS, using an SSL certificate, keeps internet more secure.<\/p>\r\n<p>A key element of a PWA is a registered service worker (see below). In essence, a worker is code that acts as a proxy between your PWA and the requests made by your PWA to the external world. Therefore your PWA needs a layer of security to prevent snooping or spoofing as well as to ensure no tampering of exchanged content.<\/p>\r\n<p>Moreover, a PWA can access many APIs (camera, file system, payments\u2026). Again, you need HTTPS to keep the information you are sharing on the web encrypted and safe.<\/p>\r\n<h3>App manifest<\/h3>\r\n<p>The manifest is a structured json file which collects all the metadata required by your PWA to find information such as the PWA\u2019s name, icons, colours and how to launch it (fullscreen, standalone, etc.). It means the manifest gives you the ability to install a PWA\u2019s icon on the device home screen, exactly like a native app installed on the device. Nevertheless, the PWA is not installed on the device, rather it is served by the browser though in a way that enhances the UX compared to a traditional website.<\/p>\r\n<h3>A registered service worker<\/h3>\r\n<p>A worker is javascript code that runs in background, in a dedicated thread. It performs several tasks including<\/p>\r\n<p>\u2022 intercept and preprocess network requests, acting as \u201cthe man in the middle\u201d between your PWA and the external world<br \/>\u2022 handle events, for instance push notifications<br \/>\u2022 help caching static resources to allow for offline usage (which directly relates to increased performance)<\/p>\r\n<p>The result is a fast \u2013 through local prefetching and caching \u2013 and reliable webapp, resilient to network issues and capable to work offline, sync later, and always serving the most recent content.<\/p>\r\n<p><em><strong>&#8220;It\u2019s the ship that made the Kessel Run in less than 12 parsecs.&#8221; <\/strong><\/em>(Han Solo)<\/p>\r\n<p>In addition the webapp is engaging as it handles events such as push notifications to prompt your users.<\/p>\r\n<p><em><strong>&#8220;Remember, your focus determines your reality.&#8221; <\/strong><\/em>(Qui-Gon Jinn)<\/p>\r\n<h3>In a nutshell<\/h3>\r\n<p>To build a PWA&#8230; take all the good stuff of a webapp and plug it into the latest javascript and browser capabilities to deliver an <em>awesome experience <\/em><em>to your users<\/em>, pretty close to a native one&#8230;<\/p>\r\n<p>&#8230;directly in their browser&#8230;<\/p>\r\n<p>&#8230;with <em>progressive <\/em>enhancements coming from the ever growing capabilities of modern browsers (i.e. the more advanced is the browser the more a PWA can deliver)&#8230;<\/p>\r\n<p>&#8230;at a lower development cost (an application that is a website and a multiplatform app at the same time)\u2026<\/p>\r\n<p>&#8230;wow!<\/p>\r\n<p>The future? Maybe. For sure a promising opportunity.<\/p>\r\n<p><strong>&#8220;Skadoosh&#8221; <\/strong>(Po &#8211; Kung Fu Panda)<\/p>\r\n","protected":false},"excerpt":{"rendered":"<p>Are Progressive Web Apps a Possible Wayout from Apps?<\/p>\n","protected":false},"author":3,"featured_media":10099,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[80,77,175,174,173],"class_list":["post-9260","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tech","tag-frontend","tag-javascript","tag-panda","tag-progressive-web-app","tag-pwa"],"_links":{"self":[{"href":"https:\/\/exmachina.ch\/en\/wp-json\/wp\/v2\/posts\/9260","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/exmachina.ch\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/exmachina.ch\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/exmachina.ch\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/exmachina.ch\/en\/wp-json\/wp\/v2\/comments?post=9260"}],"version-history":[{"count":1,"href":"https:\/\/exmachina.ch\/en\/wp-json\/wp\/v2\/posts\/9260\/revisions"}],"predecessor-version":[{"id":26553,"href":"https:\/\/exmachina.ch\/en\/wp-json\/wp\/v2\/posts\/9260\/revisions\/26553"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/exmachina.ch\/en\/wp-json\/wp\/v2\/media\/10099"}],"wp:attachment":[{"href":"https:\/\/exmachina.ch\/en\/wp-json\/wp\/v2\/media?parent=9260"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/exmachina.ch\/en\/wp-json\/wp\/v2\/categories?post=9260"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/exmachina.ch\/en\/wp-json\/wp\/v2\/tags?post=9260"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}