Javatpoint Logo
Javatpoint Logo

Progressive Web Applications

Progressive Web Applications

The full form of PWA is Progressive Web Applications. PWA is HTML 5 webpage. It is a web application like a mobile application that is stored directly on the mobile from the website. In other words, it is a website that runs on the mobile browser of the user. PWA is a new technology. PWA allows the website to be stored in your device. It creates an icon in the form of a website app, and that icon feels like a mobile application upon opening.

After the PWA icon of the website is created in the device, all the posts that are open with the help of the internet, are automatically stored in your device which does not need the internet to read the second time. It is a methodology where we combine native app experience with the Browser feature.

Generally, when you have to build applications, you have to develop that application for different platforms, such as iOS, Android, and Windows. But in the case of PWA, you do not need to develop separate applications for different platforms. You only need to create HTML 5 based webpages that can run on any mobile browser.

Characteristics of PWA

Progressive Web Applications

Progressive web applications have the following characteristics that are important to understand:

  1. Progressive: The term progressive means, a PWA application must work on any device and improve the performance of the user's mobile browser and design.
  2. Discoverable: A PWA is a website with some extra features. It can be searched via mobile searching applications like Google Chrome. App Store or Play Store is not required for this.
  3. Responsive: The UI of a progressive web app should fit the form factor and screen size of the device.
  4. App-like: A PWA application should look like a native application. Although the methods for creating, sharing, launching, and updating of the PWA are completely different from the original application.
  5. Connectivity-independent: It works even when connectivity is very low.

Advantages of PWA

  1. PWA works like an app on mobile and looks very impressive.
  2. It does not need an update.
  3. It is easily saved in the device.
  4. It's immediately loads on your mobile.
  5. It saves money and time compared to creating applications separately for android, iOS, and other platforms.
  6. Post can be read even if there is no internet.
  7. Internet data is less used in it.
  8. PWA is cheaper than the other applications.

Disadvantages of PWA

  1. It supports a limited mobile browser. It does not run on the safari, edge, and IE browser.
  2. iPhone users cannot establish connections securely in it.
  3. It makes maximum use of the battery of the device.
  4. It needs to be hosted on the server because it is a web app.
  5. It cannot be downloaded from popular app stores such as Google Play and Apple App Store.
  6. PWA does not provide the same level of support for all devices. For example, push notifications in PWA work on Android, but not on iOS.
  7. It supports limited hardware functionality.

Difference between PWA and Native Application

Feature Progressive Web Application Native Application
Function offline Yes Yes
Installation requirement There is no need to install it in mobile. It is necessary to install it in the phone.
Push-notification. It supports the push-notification feature. It also supports the push-notification feature.
Platform It supports the cross-platform. It supports the specific platform. Example iOS, Android, and Windows
Data consumption Low data consumption High data consumption
Internet requirement No internet requirement Internet requirement
Cost Low cost High cost
Update the app It does not require to update the application. It requires to update the application.
Implementation It is easy to implement. It is complex to implement.
Indexed by google Yes No
Shareable It is easy to share from anyone. It shares the entire application, so it complex.

Technical components of PWA

PWA has five components.

  1. Web App manifest
  2. Application shell
  3. Service worker
  4. Webpack
  5. Transport Layer Security (TLS)

1. Web App manifest

The web app manifest is the first component of the PWA. It is a simple JSON file that controls a user's application. Usually, it is named "manifest.json". It is the most important component for the presence of PWA. When you first connect PWA to a network, a mobile browser reads the "manifest.json" file and stores it locally in cache memory.

When there is no network access in PWA, the mobile browser uses the application's cache memory to run the PWA program while offline.

The "manifest.json" file helps the PWA to give a look of a native app. With the help of the manifest.json file, the PWA developer can control how the application is presented to the user mobile screen. The PWA developer can also set a theme for the mobile's splash-screen and the application's address bar.

The "manifest.json" file allows the PWA developer to search for a centralized location for the metadata of the web application. The JSON file defines the links to icons and icon sizes, the full and abbreviated name of an app, types, background color, theme, locations, and other visual details that are required for an app-like experience.

2. Application Shell

The application shell is the third technical component of the PWA. It is specialized to split the static and dynamic content of the application. The minimal CSS, HTML, JavaScript, and any other dynamic and static resources offer the structure for your web page. It reduces the actual content that is unique to the webpage. This component ensures a very critical approach to the development of progressive web apps.

It permits the PWA to be executed without any connection. The basic design elements of this component enable it to perform such a task. It drives especially for applications that are based on JavaScript.

3. Service Worker

A service worker is a web worker. It is a JavaScript file that runs aside from the mobile browser. In other words, it is another technical component that promotes the functionality of PWA. The service worker retrieves the resources from the cache memory and delivers the messages.

It is independent of the application to which they are connected, and has many consequences:

  • The service worker does not block the synchronized XHR, so it cannot be used in local storage (It is designed to be completely asynchronous).
  • It can receive information from the server even when the application is not running. It shows notifications in the PWA application without opening in the mobile browser.
  • It cannot directly access the DOM. Therefore, the PostMessage and Message Event Listener method is used to communicate with the webpage. The PostMessage method is used to send data, and the message event listener is used to receive data.

Things to understand about it:

  • It is a programmable-network proxy that helps you monitor how your page handles network requests.
  • It only works on the HTTPS because HTTPS is very secure, and it intercepts network requests and modifies responses.

Service worker lifecycle

The service worker lifecycle is the most complex part of the PWA. There are three stages in the lifetime of a service worker:

  1. Registration
  2. Installation
  3. Activation

Registration

A service worker is basically a JavaScript file. You need to register it in your crucial JavaScript code to use a service worker. Registration tells your browser location of the service worker and starts installing it on the background. One thing that distinguishes a service worker file from a standard JavaScript file is that a service worker runs in the background away from the mobile's main browser. This process is the first phase of the service worker's lifecycle.

The code of service worker registration is placed in the main.js file.

First, this code checks whether the browser supports the service worker. The service worker is then registered with navigator.serviceWorker.register when the service worker returns a promise. If the promise is fulfilled, the registration is successful; otherwise, the registration is failed.

Scope of registration

This scope determines the web pages that are managed by a service worker. The location of the service worker defines the default scope. Whenever you register a service worker file at the main folder of the system, it is not important to specify its scope, because it controls all webpages.

Installation

When a new service worker is registered with the help of navigator.serviceWorker.register, the JavaScript code is downloaded, and the installation state is entered. If the installation succeeds, the service worker further proceeds to the next state.

Activation

Once the service worker is successfully installed, it converts to the activation phase. If there is an open page controlled by the previous service worker, the new service worker enters the waiting state. The new service worker is activated only when no pages are loaded in the old service worker. A service worker is not activated immediately after installation.

A service worker will only be active in these cases:

  • If no service worker currently active.
  • If the user refreshes the webpage.

Service-worker.js

The service worker can manage network requests rather than caching. It roves around the latest Internet API.

1. Fetch: The Fetch API is a basic resource of the GUI. It makes it easier to control webpage requests and responses than older XMLHttprequests, and this often needs extra syntax, and its example is controlling the redirects. When a resource is requested on the network than the fetal event is terminated.

Note: It supports the CORS (Cross-Origin Resource Sharing). A local server is usually required for testing.

Fetch request example:

2. Cache API: A cache interface has been provided for the service worker API, which allows you to create a repository of responses as requested. However, this interface was designed for service workers. It does not update the memory in the cache unless specifically requested.

Features of the service worker

  • Offline: Enabling offline functionality is possibly the most demanding service worker facility.
  • Caching: The control of cache content is the most common feature for service workers.
  • Content delivery networks: The CDN and other external material may be difficult to handle. The PWA developers sometimes select out of publicly hosted software due to same-origin rules and SSL, but you may still upload scripts from CDNs.
  • Push notifications: The feature of push notifications is the best way to interact with users and visitors. This feature enhances the performance of the PWA application.
  • Background synchronization: It is another very important feature of a service worker that synchronizes tasks in the background.

4. Webpack

The webpack is the fourth component of the PWA. It is used to design the PWA front-end. It allows the PWA-developers to gather all JavaScript resources and data in one location.

5. Transport Layer Security (TLS)

The transport layer security is the fifth component of the PWA. This component is a standard for all robust and secure data exchange between any two applications. The integrity of the data requires the website's service through the HTTPS and an SSL certificate installed on the server.

How to convert the website into PWA using WordPress?

There are seven simple steps to convert a website to PWA.

The first thing to do is to log in to the WordPress admin of your website.

Progressive Web Applications

Step 2: After that, you have to go to the plugin option and click on the add new option.

Progressive Web Applications

Step 3: After this, click on the search button and search the plugin of the progressive web app and install it in WordPress.

Progressive Web Applications

Step 5: Then, activate the plugin of the progressive web app.

Progressive Web Applications

Step 6: Now, you will see many options in your dashboard (such as Application Name, Description, Icon, Color), which can customize as per your choice.

Progressive Web Applications

Step 7: Then click on the Save Settings button.

Progressive Web Applications

How do you install a PWA?

On Android phones, installing a PWA is pretty simple.

Step 1: The first thing to do is open google chrome on your mobile phone.

Progressive Web Applications

Step 2: Then, open the website, for example, Instagram.com.

Progressive Web Applications

Step 3: Now, click on the three dots of the right corner in the google chrome.

Progressive Web Applications

Step 4: Then, click on the Add to Home screen option and add it.

Progressive Web Applications

On iOS, you visit the website with the Safari browser and click the share icon. This opens a sub-menu with more icons and an option to save to the home screen.

Table of PWA framework tools

Tool Name Type Price Homepage Link Download link
React PWA Library Open source Free https://www.reactpwa.com/ https://github.com/Atyantik/react-pwa/archive/master.zip
Angular PWA Framework Open source Free https://ionicframework.com/docs/angular/pwa https://ionicframework.com/docs/angular/pwa
Vue PWA Framework Open source Free https://onsen.io/vue/ https://onsen.io/v2/guide/vue/
Ionic PWA Framework Open source Free https://ionicframework.com/pwa https://ionicframework.com/pwa
Svelte PWA Framework Open source Free https://svelte.dev/ https://svelte.dev/
PWA Builder Open source Free https://www.pwabuilder.com/ https://www.pwabuilder.com/
Webpack Module Bundler Open source Free https://webpack.github.io/ https://webpack.github.io/
Lighthouse PWA Analytics Tool Open source Free https://developers.google.com/web/ilt/pwa/lighthouse-pwa-analysis-tool https://developers.google.com/web/ilt/pwa/lighthouse-pwa-analysis-tool

Some popular examples of Progressive Web Apps

AliExpress

AliExpress is a popular e-commerce website that was introduced by the Alibaba Group. They turned their website a few years ago to a Progressive Web App for mobile phones.

After changing to a Progressive Web App, AliExpress saw incredible results:

  • 104% increase in conversions for new users.
  • 3x increase loading time in the PWA app.
  • 50% higher re-engagement.

Flipkart

In India, Flipkart is the largest e-commerce website. Flipkart has recently updated its website for mobile users to a PWA that is called Flipkart Lite. Flipkart lite combines the best of both the web and native apps. It provides a fast and uninterrupted experience to smartphone phone users.

After changing to a Progressive Web App, Flipkart saw incredible results:

  • 70% increase in conversions.
  • 40% higher re-engagement.
  • 3x increase loading time in the PWA app.
  • 65% increase in pages session in the PWA app.

Twitter Lite

Twitter is a popular platform for social media. In 2017, they changed their website to Progressive Web App for the mobile users that are called twitter lite. Twitter Lite loads posts instantly. It reduces data usage by optimizing pictures and keep on cached data.

Twitter Lite rebuilds customers with push notifications system. It also allows users to connect the Progressive Web App to their home screen of mobile phones.

After changing to a Progressive Web App, Twitter saw incredible results:

  • 75% increase in Tweets sent.
  • 20% decrease in bounce rate in the PWA.
  • 65% increase in pages session in the PWA.

Instagram

Instagram is a very popular social media app. They changed their website to Progressive Web App for mobile users. It reduces data consumption through processing photos.

After changing to a Progressive Web App, Instagram saw incredible results:

  • 77% increase in conversions.
  • 50% higher re-engagement.
  • 3x increase loading time in the PWA app.
  • 4x lower data usage in the PWA app.

BookMyShow

BookMyShow is a popular website in India that is used to book tickets online. In 2017, they changed their website to Progressive Web App for mobile users.

Some uses had many problems with the BookMyShow mobile app. But PWA solved all problems. It gives smartphone users a smooth ticket-booking experience.

After changing to a Progressive Web App, Instagram saw incredible results:

  • Over 80% increase of conversions in the PWA app.
  • Smaller size than the iOS app and android app.
  • 5x increase in conversion rates.

MakeMyTrip

MakeMyTrip is the first online travel website in India. The website owner decided to invest in a progressive web application to provide its users with a fast and appealing mobile web experience. After changing to a Progressive Web App, Instagram saw incredible results:

  • 3x increase in conversion rates.
  • Smaller size than the iOS app and android app.
  • Over 160% increase of user sessions in the PWA app.






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA




news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news