Progressive web applications (PWAs) solve many of today’s mobile-development issues
In the last few years, there has been exponential growth in the number of mobile phone users. Today, more than 60% of total internet usage is happening via mobile phone.
Obviously, the reasons include portability, cheap hardware, easy access to the internet, and the increased number of services on the internet. With more users on mobile, the optimization of user experience on the phone is essential.
For smaller companies, which often do not have native apps due to cost or time constraints, the web app is the key opportunity for winning customers by providing the best possible experience.
If companies have a dedicated native-mobile app, there’s a possibility many users will still prefer their web version in order to avoid downloading and installing an app on their phone. This could be due to hardware and memory constraints or some other personal preference.
If a company is dedicated and wants to get the maximum number of engaged customers, the experience of the web app has to be close to that of the native app.
Nowadays, the expectation from our websites is very high. Almost 25 years ago when the website was invented, its purpose was mostly to share information.
Today, the website is a grocery shop, social network, chatting place, etc. The website is expected to search for houses and hold the world map. The website is expected to give all the features of PowerPoint and Excel.
Let’s take the example of WhatsApp on your phone. When there’s no network, you can still open the app, check past messages, and even reply to someone. When the phone gets the internet connection, the messages are being automatically sent in the background.
This is what PWA promises to provide in web apps. It enables web apps to load when there is no network, sync in the background, and seamlessly do things while providing a native-like experience for your users.
Let’s discuss some of the core attributes that are missing from common nonprogressive web applications.
All the above characteristics are possible in PWAs.
A PWA is just a regular web app which attended the best university and mastered user experience.
Few people think a PWA is coupled with the latest UI frameworks like React.js, Angular 6, or Vue.js.
Well, not necessarily.
PWA has nothing to do with the framework you’re using — it only needs the required components.
This was exactly my first thought when it came to PWAs. How exactly can web apps open without the internet?
We all know native apps can open without an internet connection because when we download and install them, critical resources like UI components and some data are stored in the device. Well, this is exactly what happens in a PWA as well.
The PWA stores HTML files, CSS files, and images in the browser cache, and the developers can fully control the network call. All of these are being achieved by service workers.
PWAs have some important technical components that work together and energize the regular web app. The following components are required to develop a good PWA.
Let’s get an overview of each of them.
Our web apps talk to the network directly, and if there is no network, the screen shows the famous dinosaur.
Screen when our normal web cannot connect to the internet
Here’s an opportunity to optimize this process. For the first-time load, the service worker stores the required resources in the browser cache. And when the user visits the app next time, the service workers check the cache and return the response to the user before even checking the network.
A_service worker_ is just a component of JavaScript code that works as a proxy between the browser and the network. A service worker manages the push notifications and helps to build the offline-first web application using the browser’s cache API.
This is how the service worker performs its responsibility to empower regular websites
This can speed up the performance of your app, whether the device is connected or not connected to the internet.
The developer has full control over the behavior of the app and how it should respond in various scenarios. The service worker has its own life-cycle events.
Once the caching is complete and ready for offline visits, you can also choose to brag about it by displaying a note saying that caching is complete and the user can visit this offline as well.
The manifest file is a config JSON file that contains the information of your application, like the icon to be displayed on the home screen when installed, the short name of the application, the background color, and the theme.
If the manifest file is present, the Chrome browser will automatically trigger the web app to install the banner. If the user agrees, this adds the icon to the home screen, and the PWA is installed. Isn’t this bossy?
The following is the sample manifest file:
{
"short_name": "Spinner",
"name": "Fidget spinner",
"icons": [
{
"src": "/images/icons-192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "/images/icons-512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": "/home/?source=pwa",
"background_color": "#3367D6",
"display": "standalone",
"scope": "/home/",
"theme_color": "#3367D6"
}
Check the manifest file in action in the following screenshots.
Service workers have the ability to intercept the network requests and can modify the responses. Service workers perform all the actions on the client side. Hence, PWAs requires secure protocol HTTPS.
The service worker has the ability to receive push notifications and background sync, which definitely increases the user experience and keeps the customer engaged. Push notifications and background sync are optional but are recommended to provide a more native-like experience.
Today, there are many PWAs available out there. If you want to play around with a PWA and want to see service workers in action, visit fidgetspin.xyz, and switch to the Application tab in Chrome’s DevTools.
You can visit https://pwa.rocks/, which has a good collection of PWA apps.
There are few open-source tools available that enhance and make it easy to develop PWAs.
Google publishes the success stories of companies that have implemented PWAs. Visit this page to read more about how companies have solved problems to handle slow networks, how they optimized the user experience, and how they got up to an 80% increase in conversions and SEO performance.
This showcases various problems faced by various companies around the globe and how they solved it using PWAs. I’m pretty sure you’ll get directions on how a PWA can prove helpful for you as well.
#programming #PWA