壹、目錄及代辦事項
Table of Contents
待學習項目
貳、PWA 使用到的技術
PWA 必須在 https 協議下進行
PWA 不是一種新的技術,而是許多技術的集合體
一、Web App Manifest
透過設置 Manifest 可以實現,將 PWA 網站增加到手機主畫面,變成一個類似 Native App。
透過設置可以將網址欄位等原本瀏覽器的選單去掉,可以讓 PWA 網站更像是一個 Native App。
二、Service Worker
- 瀏覽器在後台獨立運行的腳本
- 攔截及處理網路請求、操作緩存
- 支援 push API 和 navigation API
- 後台同步 & 更新緩存
=> 透過第一次載入頁面進行緩存,接下來第二次進入頁面就不用在進行網路請求,載入速度就會快許多。
二、Web App Manifest
1. 加入 Manifest 功能
在文件中加入 Manifest.json 檔案,並在 html 的 head 做引用。
Manifest.json 檔中包含的資料
Safari 目前可能不支援的屬性,可以透過添加屬性來補足
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
跳出添加提示加入主畫面視窗的條件
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
三、Service Worker
1. 特性
- 不可以直接操作 DOM
- 需要時直接喚醒,不需要時休眠
- 離線內容開發者可控制
- 一但安裝,永久存活,除非手動卸載
- 必須在 https 或 localhost 環境下執行
- 使用 Promise