Science Knowings: JavaScript Course For Social Media

Progressive Web Apps (PWAs)

Progressive Web Apps (PWAs)

Welcome to Progressive Web Apps! We're coming from Test-Driven Development in JavaScript, where we learned about writing reliable code.

Today, we'll dive into the exciting world of PWAs, which are web applications that combine the best of the web and native apps.

What are PWAs?

PWAs are web applications that:

  • Load like a website
  • Look and feel like an app
  • Can work offline
  • Can send push notifications

They offer a seamless user experience that bridges the gap between web and native apps.

Benefits of PWAs

PWAs provide several benefits:

  • Improved performance: PWAs load and respond faster due to caching.
  • Enhanced user experience: PWAs offer native-like features like push notifications and offline support.
  • Reduced development costs: PWAs can be built using existing web technologies, reducing development time and costs.

Challenges of PWAs

PWAs also come with some challenges:

  • Device compatibility: PWAs may not work consistently across all devices and browsers.
  • App store discoverability: PWAs are not listed in app stores, making it challenging for users to find them.
  • Limited access to native features: PWAs have limited access to native device features compared to native apps.

Creating a PWA

To create a PWA:

  1. Use a service worker to cache assets and handle offline requests.
  2. Create a manifest file to define app metadata, icons, and other settings.
  3. Implement push notifications to engage users.
  4. Design for offline functionality by storing data locally.

Service Workers

Service workers are scripts that run in the background and manage caching, offline requests, and push notifications.



Manifests are JSON files that describe the PWA and provide information such as:

  • App name
  • Icons
  • Start URL
  • Display mode
   "name": "My PWA",
   "icons": [{
       "src": "icon.png",
       "sizes": "192x192"
   "start_url": "index.html"

Push Notifications

Push notifications allow PWAs to send updates and messages to users even when the app is not open.

self.registration.showNotification('New Notification', {
   body: 'This is a test notification' }

Offline Capabilities

PWAs can work offline by storing data locally using the IndexedDB API or localStorage.'myDatabase', 1);
localStorage.setItem('name', 'John');

Examples of PWAs

Notable examples of PWAs include:

  • Twitter Lite
  • Instagram Lite
  • Uber
  • Spotify

Case Study: Twitter Lite

Twitter Lite is a PWA version of Twitter that offers a faster and data-efficient experience.

  • Uses a service worker to cache tweets for offline reading.
  • Implements push notifications to alert users of new tweets.
  • Reduced data usage by up to 90% compared to the native app.

Best Practices for PWAs

To create effective PWAs, follow these best practices:

  • Use a service worker for offline functionality.
  • Create a manifest file for app metadata and icons.
  • Implement push notifications for user engagement.
  • Design for offline functionality by storing data locally.
  • Test your PWA thoroughly across different devices and browsers.

PWAs vs. Native Apps

PWAs differ from native apps in several ways:

FeaturePWANative App
DevelopmentWeb technologiesPlatform-specific languages (e.g., Swift, Java)
InstallationWeb store or direct linkApp store
Offline functionalityLimitedFull
Native featuresLimited accessFull access

Future of PWAs

PWAs are evolving rapidly, with new features and capabilities being added constantly.

  • Improved performance and reliability
  • Enhanced offline capabilities
  • Increased adoption by major platforms and browsers

Next Up: Web Components

In the next session, we'll explore Web Components, a powerful set of technologies that allow you to create and reuse custom elements and components on the web.

Join us to enhance your web development skills and create dynamic and engaging experiences!