Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
ゼロから始めるPWA入門
Search
syumai
April 06, 2018
Programming
6.4k
6
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
ゼロから始めるPWA入門
syumai
April 06, 2018
More Decks by syumai
See All by syumai
Workers Cache を知る
syumai
0
360
自分的「カンファレンスの楽しみ方」
syumai
0
220
go-spidermonkeyでAIエージェントのCode Modeを実装する
syumai
3
1.6k
作って学ぶ、 JSX (TSX) ランタイムの基本
syumai
7
2.1k
Oxlintのカスタムルールの現況
syumai
6
2.2k
Oxlintはいかにしてtsgolintのlint ruleを呼び出しているのか
syumai
2
1.6k
『[入門] Cloudflare Workers』本はなぜ誕生したのか
syumai
0
650
tsgolintはいかにしてtypescript-goの非公開APIを呼び出しているのか
syumai
9
3.4k
知られているようで知られていない JavaScriptの仕様 4選
syumai
3
1.3k
Other Decks in Programming
See All in Programming
すこし踏み込む CancellationToken
htkym
2
1.7k
C#の現在地 進化の歴史と、AI時代の.NET Everywhere
neuecc
5
5.2k
コードで差別化できない時代の ソフトウェアエンジニアリング / Software Engineering in an Era Where Code Doesn’t Differentiate
kishida
2
180
ソニーのクラウド共通基盤の変遷とAI時代の開発スタイルに合わせた進化 / The Journey of Sony’s Common Cloud Platform and Its Evolution for AI-Native Development
kenjiyoneyama
0
270
Next.js: The final boss of Web Performance
guaca
0
260
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Rails World 2026, Austin, Texas
marcoroth
0
220
AWSに止められる覚悟してますか?
morizo_1984
2
540
npm との違いを手がかりにGo の依存管理を理解したい
optim
0
340
見えないものを探る要求要件定義に必要な基本的思考 / invisible-requirement-thinking
minodriven
15
8.5k
Event is what happens
moro
2
780
HTML-in-Canvasで作る未来のWeb UI表現
clockmaker
5
5.1k
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
190
Featured
See All Featured
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
1
630
エンジニアに許された特別な時間の終わり
watany
109
250k
The Spectacular Lies of Maps
axbom
PRO
1
1.1k
How to train your dragon (web standard)
notwaldorf
96
6.9k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
550
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3.1k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
990
[SF Ruby Conf 2025] Rails X
palkan
3
1.5k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.7k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
600
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3.2k
Transcript
ゼロから始めるPWA入門 @__syumai 2018.4.6 Webエンジニア勉強会 #06
自己紹介 しゅーまい ダックリングズ株式会社 フロントエンド / サーバーサイド 担当 VR / ウェディング関連のサービスをやってるベンチャー
エンジニアは2名 4月で新卒3年目 最近はReact Native / Rails / Vue.jsをやってます Twitter: @__syumai(アンダーバー2 つ) GitHub: syumai
入門と言うより、勉強の記録です…汗 => github.com/syumai/sw-playground
目次 1. Progressive Web App (PWA) とは 2. PWAの構成要素 3.
開発ツールについて 4. Service Workerで遊んでみた 5. 次に試したい事
Progressive Web Appとは
『はじめてのプログレッシブウェブアプリ | Web | Google Developers』 https://developers.google.com/web/fundamentals/codelabs/your-first-pwapp/?hl=ja
ウェブとアプリの両方の利点
ウェブの利点 • 手軽 • 更新が楽 • データが軽い
アプリの利点 • オフライン利用可 • Push通知 • 動作が軽い
アプリの利点 • オフライン利用可 • Push通知 • 動作が軽い ↑PWAなら実現できる!
利用事例 • Twitter Lite ◦ データセーバー機能あり、省データに特化 • Instagram ◦ 画像フィルタも使える
None
初回ダウンロード => 4.1MB アプリ => 約35MB Twitter Lite
初回ダウンロード => 47.8KB アプリ => 約34MB Instagram
PWAの構成要素
主要なPWAの構成要素 • Service Worker (一番大事!) • Cache Storage • Web
App Manifest
今回紹介しないもの • Web Push API / Web Notification API ◦
昔はGCMとか必要で設定めっちゃ大変だった • IndexedDB ◦ SWから非同期的に扱えるNoSQL DB 他にもいろいろあります
Service Worker
Service Worker • Webページのバックグラウンドで走るスクリプト • 別のスクリプトからインストールする • 閲覧中のページのDOM操作などは行わない • ブラウザを閉じても、通知の待ち受けなどに使える
• Webのリクエストに介入できる
Service Worker • Webページのバックグラウンドで走るスクリプト • 別のスクリプトからインストールする • 閲覧中のページのDOM操作などは行わない • ブラウザを閉じても、通知の待ち受けなどに使える
• Webのリクエストに介入できる ↑リクエストを捕まえて、任意のレスポンスを返せる!
Service Worker • かなり強力な機能のため、SSL環境 or localhostでしか動きません
Cache Storage
Cache Storage • 開発者が完全にコントロール出来るキャッシュストレージ • html, css, js, 画像など、Webサイト上の任意のファイルを保存出来る •
ドメインごとに保存される • ネームスペースが切れる (v1など) • 明示的に削除しない限りクリアされない
Cache Storageから取り出して Service Workerから返す ↓ オフラインで完全に動作する Webサイトが作れる!
Web App Manifest
Web App Manifest • Webサイトのアプリとしての振る舞いを定義する • アイコン • アプリ名 •
テーマカラー (AndroidのChrome等で有効) • ホームURL • デバイスの向き • フルスクリーンかどうか など
None
インストールしたアプリと同じように、 ホームから開けるようになる!
開発ツールについて
Chrome Dev Toolsが最強
これ!
Chrome Dev Tools • Service Workerのデバッグが簡単 • バックグラウンドで動いていても、ブレークポイント置いたり出来る • オフライン環境の再現もチェック一つで
• リロードでService Workerをアップデートできるオプションも
Chrome Dev Tools • Cache Storageの中身を簡単に見れる • 即座に削除も可能
開発ツールの詳細は、 Totally Tooling Tips (S3) をYouTubeで! https://www.youtube.com/playlist?list=PLNYkxOF6rcIB3ci 6nwNyLYNU6RDOU3YyL
Lighthouse
Google公式のPWA監査ツール
Lighthouse • PWAのパフォーマンスをチェックしてレポートを作ってくれる • Chrome拡張で簡単に入る
Service Workerで遊んでみた
Service Worker • リクエストに介入できる • => fetchのイベントを捕まえて、別のレスポンスを返せる
普通の使い方
インストール時にキャッシュ https://developers.google.com/web/fundamentals/primers/service-workers/?hl=ja
リクエストを捕まえて、キャッシュからレスポンスを返す https://developers.google.com/web/fundamentals/primers/service-workers/?hl=ja
今回やってみた事 => 存在しないページを返す
Dummy Router • ページをめくってpagesディレクトリ配下のHTMLをガンガン読む
pages/x.htmlと言うファイルは無い
テンプレートのHTMLをコード内に用意 https://github.com/syumai/sw-playground/blob/master/dummy-router/sw.js
テンプレートからHTMLを生成して返す https://github.com/syumai/sw-playground/blob/master/dummy-router/sw.js
デモ https://syumai.github.io/sw-playground/dummy-router/
次にやった事
キャッシュしたテンプレート +JSONからレスポンス生成!
デモ https://syumai.github.io/sw-playground/basic-progressive-blog/
レスポンスの軽量化! • HTMLはあるけど、取りに行かず、ServiceWorkerで生成! • HTML => 28KB • SW +
JSON => 8KB
大変だったこと • 任意のファイルをキャッシュから取り出す作業 • 任意のレスポンスで e.respondWith => Responseオブジェクトを返すasync functionを書いて頑張った
次にやりたい事 • Nuxt.jsのPWAモジュール • APIサーバーとの連携
ダックリングズでは React Nativeを一緒にやりたい人を 募集中です!