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

Arrow left icon
Profile Icon Love
Arrow right icon
Free Trial
Paperback Jul 2018 354 pages 1st Edition
eBook
₱1256.99 ₱1796.99
Paperback
₱2245.99
Subscription
Free Trial
Arrow left icon
Profile Icon Love
Arrow right icon
Free Trial
Paperback Jul 2018 354 pages 1st Edition
eBook
₱1256.99 ₱1796.99
Paperback
₱2245.99
Subscription
Free Trial
eBook
₱1256.99 ₱1796.99
Paperback
₱2245.99
Subscription
Free Trial

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
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 : 9781787125421
Vendor :
Google
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

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

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 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
$199.99 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 ₱260 each
Feature tick icon Exclusive print discounts
$279.99 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 ₱260 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 6,992.97
React Cookbook
₱2500.99
Progressive Web Application Development by Example
₱2245.99
Mastering The Faster Web with PHP, MySQL, and JavaScript
₱2245.99
Total 6,992.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

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.