Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Progressive Web Application Development by Example
Progressive Web Application Development by Example

Progressive Web Application Development by Example: Develop fast, reliable, and engaging user experiences for the web

eBook
₹2621.99
Paperback
₹3276.99
Subscription
Free Trial
Renews at ₹800p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Table of content icon View table of contents Preview book icon Preview Book

Progressive Web Application Development by Example

Creating a Home Screen Experience with a Web Manifest

Progressive web apps make a website feel like a native app. For a business stakeholder, this gives them the opportunity to use a free app store to engage customers. For real users, it means that the sites they routinely visit can be installed without any friction. Either way, it is a marketing opportunity to increase engagement by delivering a better user experience and an natural way to place their brand's icon in the customer's most important location: their homescreen.

Each platform (operating system and browser) implements a homescreen and how the application is launched in their own way, but most involve some sort of bookmarking process and opening experience driven by the web manifest file.

Chrome for Android places installed PWAs in the application shelf and allows PWAs to be managed like a native app in the...

Why add to homescreen is important

Reengagement is a key advantage that native applications have enjoyed over websites. The presence of their icon on the user's homescreen and app shelves provides quick, visual access to the brand's experience. It's subtle, but that icon is a constant visual reminder of the customer's relationship to the brand.

Browsers have provided a built-in mechanism for us to bookmark websites using favorites for years now, but these lists have become cluttered messes we often forget about. We have also been able to add bookmarks to the desktop, start menu, and even the windows task bar, but the process is manual, and most consumers do not know that it exists.

More modern browsers have started logging pages that you frequently visit and providing bookmarks to these common destinations when you open a new tab. This is an example of making...

Making your PWA iOS web app capable

When Apple introduced iOS, the original app recommendation was to use HTML5, CSS3, and JavaScript to create rich client-side user experiences. Apple has not removed web app support and has enhanced some capabilities over time. The iOS web app experience is driven by custom metadata that's added to a web page's HEAD.

Much of the Apple meta data has served as a model for the modern web manifest specification. Before the web manifest specification was created, Chrome on Android integrated support for the Apple meta data to drive a similar experience.

The web app experience on iOS is triggered when your website contains Apple-specific META tags, corresponding icons, and when the user has added your site to their homescreen.

The first piece you need is a png file as the default homescreen icon. The file should be named apple-touch-icon...

The web manifest specification

The Web Manifest describes the progressive web applications with meta data and JSON formatting. Browsers parse the manifest file to create the add to homescreen icon and launch the experiences.

Now, instead of polluting each page's HEAD with extra meta data, the browser can load an external file containing standard properties and values formatted using JSON.

The web manifest specification (https://w3c.github.io/manifest/) provides some guidelines for browsers to establish an add to homescreen experience. How browsers implement the experience is left open ended, making an avenue for creativeness. I will cover this topic in more detail after reviewing the manifest file.

Referencing the web manifest file

...

Validating web manifest files

The web manifest is a simple JSON document, but it's easy to make typos or forget things. If your site is not properly registering the manifest file, you will need to troubleshoot the issue. Fortunately, there are a few resources to help you validate your file.

Google hosts a simple online validator (https://manifest-validator.appspot.com) where you can enter either a URL or just paste the manifest code into the page. It will parse your manifest and let you know if there is an issue:

The nodejs Web Manifest Validator (https://github.com/san650/web-app-manifest-validator) is a module you can include in your automated testing workflow to validate a manifest file. It is a couple of years old, so you may need to fork the project and update it if you are using newer manifest features. Remember that the manifest specification is not final and can...

The Chrome improved add to homescreen experience

Some time in 2017, the Chrome team announced changes to the PWA installation experience called the improved add to homescreen experience. At the time, it was not as much about the automatic prompt, but that has been part of the change. It has more to do with how PWAs behave on Android and that it is more like a native application.

These changes were multifaceted and start with the web manifest scope property. This property is relatively new but allows the browser to know how to limit PWA functionality on an origin (domain name).

When you set the scope value to /, you are telling the platform that the progressive web application's capabilities apply to all paths within the origin. This may not always be the case, especially on larger sites and enterprise applications. Often, these sites are segmented into different applications...

The add to homescreen experience

The emergence of an automatic prompt to a visitor to add your progressive web app to their homescreen is exciting. In the past, Chrome would eventually display a prompt to install a progressive web app, but that has changed recently. The rules determining when the prompt triggers are still valid, but now only trigger the beforeinstallprompt event.

How the user prompt triggers is where each browser can choose a different path. Some of the requirements are defined in the web manifest specification, but the experience is left open ended for browsers to implement as they see fit.

Right now, Chrome has the most mature process. They established the following criteria to automatically trigger the add to homescreen experience:

  • Has a web app manifest file with:
    • A short_name (used on the homescreen)
    • A name (used in the banner)
    • A 144 x 144 .png icon (the...

Your add to homescreen responsibilities

At Google I/O 2018, it was announced that Chrome on Android will no longer include an automated add to homescreen prompt. Instead, it is your responsibility to create the user experience. Ultimately, the Chrome team decided to fall more in line with how other browser vendors are crafting their experiences.

The manifest specification takes time to define skeleton rules and minimal requirements for the add to homescreen experience. Rather than limiting all browsers to the same rules, the specification defines instalability signals that can be used as part of the add to homescreen prompt algorithm.

The prompt sequence should honor a modicum of privacy considerations and wait for the document to be fully loaded before issuing a prompt. The process should also allow the user to inspect the application name, icon, start URL, origin, and other...

Tracking homescreen installs

Once the homescreen install prompt displays, the user can choose to add the PWA to their homescreen, or ignore the prompt. Businesses should track and measure everything possible to make better decisions. Knowing how many homescreen installs there have been and what rate customers install their PWA provides insight into their marketing and technology investments.

Chrome supports the beforeinstallprompt event, which can be used to track this activity. You can add a handler to this event and log each user's choice:

window.addEventListener('beforeinstallprompt', function(event) { 
  event.userChoice.then(function(result) {                                  
 
if(result.outcome == 'dismissed') {                                         
  // They dismissed, send to analytics 
}else { 
  // User accepted! Send to analytics 
} 
})...

Polyfiling the homescreen experience on iOS and other legacy browsers

A common question developers and business owners ask is how to enable progressive web application features on iOS and older browsers like Internet Explorer. While all features cannot be hacked in these browsers, much of it can.

When the iPhone was released, the initial application model was the web. They created an advanced experience for web apps that included the add to homescreen experience. Unfortunately, they did not make an automatic prompt experience. Who knows how advanced this might be today if developers did not cry out for the native app model.

What we can do is still leverage this capability and use Matteo Spinelli's add to homescreen library (http://cubiq.org/add-to-home-screen) in combination with Apple's guidelines. Doing so allows your web apps to launch from user's home screens...

Microsoft Edge and Internet Explorer

When Windows 8 shipped, Microsoft quietly shipped support for what they called a Hosted Web App (HWA). These are websites that reference a valid web manifest file and are served via HTTPS.

HWAs were an early precursor to progressive web apps. The obvious difference is no service worker requirement, which you would expect since the concept of a service worker had not be created yet.

To be a HWA, you would create a .appx file for your application containing the manifest file and a reference to the public URL. Then, you would submit the HWA appx to the Windows Store and consumers could install the HWA from the store.

The advantage of being a HWA is that these web apps have full access to all the Windows platform APIs, just like any native application. The reason that they have this privilege is that once installed, they form the store and are...

Benefits await without Polyfils

Even if you don't polyfil the add to homescreen behavior, your web application will see user engagement gains on iOS and other non-PWA platforms. Many companies are publicly sharing their improvements in various progressive web application case studies.

Wego, an online air travel booking service, reported a 50% increase in conversions and 35% longer sessions on iOS. Mynet increased page views by 15%, and a 23% lower bounce rate on iOS. Lancôme increased iOS sessions by 53%. These are just a small sampling of positive progressive web application case studies.

These companies are reaping the rewards of PWAs on iOS because, by nature, properly architected websites perform better. Plus, creating a progressive web application forces you to put the customer first, not the developer. When you do this, you create a better user experience, which...

Testing the add to homescreen experience in Chrome

The developer experience would not be complete without the ability to test the add to homescreen experience. Chrome has added tooling which allows you to see how your web manifest file is interpreted and manually trigger the prompt.

Launch Chrome's developer tools by using F12 and select the Application tab. There are many choices to help you debug various aspects of a progressive web application. Under Application, there is a Manifest choice. This will display the properties of your web manifest file, including each icon. This is a quick way for you to determine if your manifest is interpreted correctly, as you can see in the following screenshot:

There is also a link to manually trigger the Add to Home Screen experience. Check out the following screenshot:

Clicking the link in the developer tools will trigger the Add...

Summary

The line between native and progressive web applications is very blurred, thanks in part to the web manifest and add to home screen experience. No longer is the homescreen reserved to native applications; the web is welcomed by all platforms.

Today, most browsers provide a first-class app experience for progressive web applications, and while Apple has yet to adopt the progressive web application standards, they were the first to make the web into an app experience. It is up to developers and businesses to adopt and implement the rich add to homescreen capabilities.

Triggering the add to homescreen experience is the first step in levelling up your web presence.

Even if the user has not added your PWA to their homescreen, you can still take advantage of progressive web app features. However, before we dive into service workers, let's take a look at adding SSL to your...

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • • Explore different models and patterns required to develop progressive web applications
  • • Create applications requiring shorter runtime for attracting more users
  • • Study different projects to understand the fundamentals of progressive web applications

Description

Are you a developer that wants to create truly cross-platform user experiences with a minimal footprint, free of store restrictions and features customers want? Then you need to get to grips with Progressive Web Applications (PWAs), a perfect amalgamation of web and mobile applications with a blazing-fast response time. Progressive Web Application Development by Example helps you explore concepts of the PWA development by enabling you to develop three projects, starting with a 2048 game. In this game, you will review parts of a web manifest file and understand how a browser uses properties to define the home screen experience. You will then move on to learning how to develop and use a podcast client and be introduced to service workers. The application will demonstrate how service workers are registered and updated. In addition to this, you will review a caching API so that you have a firm understanding of how to use the cache within a service worker, and you'll discover core caching strategies and how to code them within a service worker. Finally, you will study how to build a tickets application, wherein you’ll apply advanced service worker techniques, such as cache invalidation. Also, you'll learn about tools you can use to validate your applications and scaffold them for quality and consistency. By the end of the book, you will have walked through browser developer tools, node modules, and online tools for creating high-quality PWAs.

Who is this book for?

Progressive Web Application Development by Example is for you if you’re a web developer or front-end designer who wants to ensure improved user experiences. If you are an application developer with knowledge of HTML, CSS, and JavaScript, this book will help you enhance your skills in order to develop progressive web applications, the future of app development.

What you will learn

  • • Explore the core principles of PWAs
  • • Study the three main technical requirements of PWAs
  • • Discover enhancing requirements to make PWAs transcend native apps and traditional websites
  • • Create and install PWAs on common websites with a given HTTPS as the core requirement
  • • Get acquainted with the service worker life cycle
  • • Define service worker caching patterns
  • • Apply caching strategies to three different website scenarios
  • • Implement best practices for web performance

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jul 24, 2018
Length: 354 pages
Edition : 1st
Language : English
ISBN-13 : 9781787282346
Vendor :
Google
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want

Product Details

Publication date : Jul 24, 2018
Length: 354 pages
Edition : 1st
Language : English
ISBN-13 : 9781787282346
Vendor :
Google
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
₹800 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
₹4500 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just ₹400 each
Feature tick icon Exclusive print discounts
₹5000 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just ₹400 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 10,203.97
React Cookbook
₹3649.99
Progressive Web Application Development by Example
₹3276.99
Mastering The Faster Web with PHP, MySQL, and JavaScript
₹3276.99
Total 10,203.97 Stars icon

Table of Contents

11 Chapters
Introduction to Progressive Web Apps Chevron down icon Chevron up icon
Creating a Home Screen Experience with a Web Manifest Chevron down icon Chevron up icon
Making Your Website Secure Chevron down icon Chevron up icon
Service Workers – Notification, Synchronization, and Our Podcast App Chevron down icon Chevron up icon
The Service Worker Life Cycle Chevron down icon Chevron up icon
Mastering the Cache API - Managing Web Assets in a Podcast Application Chevron down icon Chevron up icon
Service Worker Caching Patterns Chevron down icon Chevron up icon
Applying Advanced Service Worker Cache Strategies Chevron down icon Chevron up icon
Optimizing for Performance Chevron down icon Chevron up icon
Service Worker Tools Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.