Skip to main content

Lesson 2 of 9

Progressive Web Apps (PWA)

Progressive Web Apps use Service Workers and Web Manifests to make websites work offline, install like native apps, and send push notifications. PWAs bridge the gap between web and mobile apps.

35 minBy Priygop Editorial TeamUpdated 2026Peer Reviewed & Verified

PWA Components

  • Web Manifest - manifest.json defines app name, icons, theme color, display mode. Enables 'Add to Home Screen' prompt
  • Service Worker - JavaScript file that acts as a proxy between browser and network. Caches assets for offline access
  • HTTPS required - Service Workers only work on secure origins (localhost for development, HTTPS for production)
  • Offline support - Service Worker intercepts fetch requests and serves cached responses when offline
  • Installability - Chrome shows install prompt when manifest + Service Worker are properly configured
  • Background sync - Queues network requests made while offline and replays them when connection returns

PWA Setup Code

PWA Setup Code
<!-- manifest.json link in HTML -->
<link rel="manifest" href="/manifest.json">
<meta name="theme-color" content="#E44D26">

<!-- manifest.json -->
{
  "name": "My Portfolio",
  "short_name": "Portfolio",
  "start_url": "/",
  "display": "standalone",
  "background_color": "#ffffff",
  "theme_color": "#E44D26",
  "icons": [
    { "src": "/icon-192.png", "sizes": "192x192", "type": "image/png" },
    { "src": "/icon-512.png", "sizes": "512x512", "type": "image/png" }
  ]
}

<!-- Register Service Worker in HTML -->
<script>
if ('serviceWorker' in navigator) {
  navigator.serviceWorker.register('/sw.js')
    .then(reg => console.log('SW registered:', reg.scope))
    .catch(err => console.log('SW failed:', err));
}
</script>

<!-- sw.js - Basic Service Worker -->
const CACHE = 'portfolio-v1';
const ASSETS = ['/', '/index.html', '/style.css', '/app.js'];

self.addEventListener('install', event => {
  event.waitUntil(
    caches.open(CACHE).then(cache => cache.addAll(ASSETS))
  );
});

self.addEventListener('fetch', event => {
  event.respondWith(
    caches.match(event.request)
      .then(cached => cached || fetch(event.request))
  );
});

Tip

Start your PWA journey by adding just two things to an existing website: a manifest.json file and a basic Service Worker that caches your HTML and CSS. This takes less than 30 minutes and immediately makes your site installable and available offline. Run a Lighthouse audit to see what else is needed for full PWA compliance.

Diagram
Loading diagram…

PWAs deliver installable, offline-capable app experiences using web technologies

Quick Quiz: PWA

Key Takeaways

  • Progressive Web Apps use Service Workers and Web Manifests to make websites work offline, install like native apps, and send push notifications.
  • Web Manifest - manifest.json defines app name, icons, theme color, display mode. Enables 'Add to Home Screen' prompt
  • Service Worker - JavaScript file that acts as a proxy between browser and network. Caches assets for offline access
  • HTTPS required - Service Workers only work on secure origins (localhost for development, HTTPS for production)

Hands-on Practice Tools for this Course

Test what you learn using these free in-browser developer utilities (no signup required).

All 40+ Tools

Topics in This Module

0/9 done