Chuyển đến nội dung
Skillpedia
Website và giao diện (frontend)48k · #5515

progressive-web-app

Skill này làm gì

PWA là một website hoạt động như ứng dụng, cho phép cài đặt trên điện thoại và chạy khi không có mạng. Nó dùng các công nghệ hiện đại để nhanh và đáng tin cậy.

Khi nào nên dùng

  • ✓Khi bạn muốn website của mình hoạt động khi không có mạng.
  • ✓Khi bạn muốn website có thể cài lên màn hình chính của thiết bị.
  • ✓Khi bạn muốn cải thiện tốc độ và độ ổn định của website.

Liên kết skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/progressive-web-app/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/progressive-web-app/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Làm sao để website của tôi hoạt động khi không có mạng và cài đặt được như một ứng dụng?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Cách làm là dùng một “manifest” mô tả ứng dụng và một “service worker”, tức đoạn code chạy nền trong trình duyệt. Code này quản lý bộ nhớ đệm (các file đã lưu) và cho phép website hoạt động mà không cần kết nối.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Progressive Web Apps (PWAs)

Overview

A Progressive Web App is a web application that uses modern browser capabilities to deliver a fast, reliable, and installable experience — even on unreliable networks. The three required pillars are:

  1. HTTPS — Required in production for service workers to register (localhost is exempt for development).
  2. Web App Manifest (manifest.json) — Makes the app installable and defines its appearance on device home screens.
  3. Service Worker (sw.js) — A background script that intercepts network requests, manages caches, and enables offline functionality.

When to Use This Skill

  • Use when the user wants their web app to work offline or on unreliable networks.
  • Use when building a mobile-first web project where users should be able to install the app to their home screen.
  • Use when the user asks about caching strategies, service workers, or improving web app performance and resilience.
  • Use when the user mentions Workbox, web app manifests, background sync, or push notifications for the web.
  • Use when the user asks "can my website be installed like an app?" or "how do I make my site work offline?" — even if they don't use the word PWA.

Deliverables Checklist

Every PWA implementation must include these files at minimum:

  • index.html — Links manifest, registers service worker
  • manifest.json — Full app metadata and icon set
  • sw.js — Service worker with install, activate, and fetch handlers
  • app.js — Main app logic with SW registration and install prompt handling
  • offline.html — Fallback page shown when navigation fails offline (required — missing file will cause install to fail)

Step 1: Web App Manifest (manifest.json)

Defines how the app appears when installed. Must be linked from <head> via <link rel="manifest">.

{
  "name": "My Awesome PWA",
  "short_name": "MyPWA",
  "description": "A fast, offline-capable Progressive Web App.",
  "start_url": "/",
  "scope": "/",
  "display": "standalone",
  "orientation": "portrait-primary",
  "background_color": "#ffffff",
  "theme_color": "#0055ff",
  "icons": [
    {
      "src": "/assets/icons/icon-192x192.png",
      "sizes": "192x192",
      "type": "image/png",
      "purpose": "any maskable"
    },
    {
      "src": "/assets/icons/icon-512x512.png",
      "sizes": "512x512",
      "type": "image/png",
      "purpose": "any maskable"
    }
  ],
  "screenshots": [
    {
      "src": "/assets/screenshots/desktop.png",
      "sizes": "1280x720",
      "type": "image/png",
      "form_factor": "wide"
    }
  ]
}

Key fields:

  • display: standalone hides browser UI; minimal-ui shows minimal controls; browser is standard tab.
  • purpose: "maskable" on icons enables adaptive icons on Android (safe zone matters — keep content in center 80%).
  • screenshots is optional but required for Chrome's enhanced install dialog on desktop.

Step 2: HTML Shell (index.html)

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>My Awesome PWA</title>

  <!-- PWA manifest -->
  <link rel="manifest" href="/manifest.json">

  <!-- Theme color for browser chrome -->
  <meta name="theme-color" content="#0055ff">

  <!-- iOS-specific (Safari doesn't fully use manifest) -->
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="default">
  <meta name="apple-mobile-web-app-title" content="MyPWA">
  <link rel="apple-touch-icon" href="/assets/icons/icon-192x192.png">

  <link rel="stylesheet" href="/styles.css">
</head>
<body>
  <div id="app">
    <header><h1>My PWA</h1></header>
    <main id="content">Loading...</main>
    <!-- Optional: install button, hidden by default -->
    <button id="install-btn" hidden>Install App</button>
  </div>
  <script src="/app.js"></script>
</body>
</html>

Step 3: Service Worker Registration & Install Prompt (app.js)

// ─── Service Worker Registration ───────────────────────────────────────────
if ('serviceWorker' in navigator) {
  window.addEventListener('load', async () => {
    try {
      const registration = await navigator.serviceWorker.register('/sw.js');
      console.log('[App] SW registered, scope:', registration.scope);
    } catch (err) {
      console.error('[App] SW registration failed:', err);
    }
  });
}


…
Câu hỏi thường gặp

“Service worker” là gì?

Đó là một đoạn script (code) chạy ngầm trong trình duyệt. Nó có thể chặn các yêu cầu mạng, quản lý việc lưu file đệm và cho phép website hoạt động khi offline.

“Web App Manifest” là gì?

Đó là file JSON chứa thông tin về web app của bạn, như tên, biểu tượng, màu sắc và cách nó hoạt động khi được cài đặt. Nhờ file này, website có thể được thêm vào màn hình chính của thiết bị.

Tôi có cần HTTPS không?

Có, để service worker hoạt động trên website đã công bố (production), cần dùng HTTPS. Localhost (môi trường phát triển) là ngoại lệ.

Chi tiết

Mô tả gốc của tác giả

Build Progressive Web Apps (PWAs) with offline support, installability, and caching strategies. Trigger whenever the user mentions PWA, service workers, web app manifests, Workbox, 'add to home screen', or wants their web app to work offline, feel native, or be installable.

repo: sickn33/agentic-awesome-skills

Độ phổ biến

Sao GitHub
48k
Vị trí xếp hạng
#5515
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự