Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Ember Service Worker - EmberFest Edition
Search
Marten
October 28, 2016
Programming
5
580
Ember Service Worker - EmberFest Edition
Marten
October 28, 2016
Tweet
Share
More Decks by Marten
See All by Marten
Ember.Object
martndemus
0
67
EmberJS Amsterdam - Closure Actions
martndemus
0
86
Other Decks in Programming
See All in Programming
「今のプロジェクトいろいろ大変なんですよ、app/services とかもあって……」/After Kaigi on Rails 2024 LT Night
junk0612
5
2.1k
Why Jakarta EE Matters to Spring - and Vice Versa
ivargrimstad
0
1.1k
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
250
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
100
初めてDefinitelyTypedにPRを出した話
syumai
0
410
GitHub Actionsのキャッシュと手を挙げることの大切さとそれに必要なこと
satoshi256kbyte
5
430
聞き手から登壇者へ: RubyKaigi2024 LTでの初挑戦が 教えてくれた、可能性の星
mikik0
1
130
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
900
Quine, Polyglot, 良いコード
qnighy
4
640
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
1
290
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
170
AWS Lambdaから始まった Serverlessの「熱」とキャリアパス / It started with AWS Lambda Serverless “fever” and career path
seike460
PRO
1
260
Featured
See All Featured
Navigating Team Friction
lara
183
14k
Faster Mobile Websites
deanohume
305
30k
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
A designer walks into a library…
pauljervisheath
204
24k
Being A Developer After 40
akosma
86
590k
Designing on Purpose - Digital PM Summit 2013
jponch
115
7k
It's Worth the Effort
3n
183
27k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
410
A better future with KSS
kneath
238
17k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
47
2.1k
Making the Leap to Tech Lead
cromwellryan
133
8.9k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Transcript
A pluggable approach to Service Workers
Marten Schilstra @martndemus
None
None
None
None
A pluggable approach to Service Workers
None
PWA & Ember Serv•ice Work•er (sûrˈvĭs wûrˈkər)
Progressive Web Apps PWA & Ember Serv•ice Work•er (sûrˈvĭs wûrˈkər)
Progressive Web Apps a Service Worker ➡ Ember PWA &
Ember Serv•ice Work•er (sûrˈvĭs wûrˈkər)
Progressive Web Apps a Service Worker ➡ Ember ember-service-worker PWA
& Ember Serv•ice Work•er (sûrˈvĭs wûrˈkər)
Progressive Web Apps
Progressive Web Apps Web apps that feel like native apps
by means of progressive enhancement
Service Workers Web App Manifest & Progressive Web Apps
Service Workers Web App Manifest Progressive Web Apps
Service Workers Web App Manifest Offline Progressive Web Apps
Service Workers Web App Manifest Offline Push Notifications Progressive Web
Apps
Service Workers Web App Manifest Offline Push Notifications Background Sync
Progressive Web Apps
Service Workers Web App Manifest Offline Push Notifications Background Sync
Add to home screen Progressive Web Apps
Service Workers Web App Manifest Offline Push Notifications Background Sync
Add to home screen Display mode Progressive Web Apps
https://developers.google.com/web/showcase/
https://developers.google.com/web/showcase/
Still not convinced? http://bit.ly/pwa-talk
Still not convinced? http://bit.ly/pwa-talk
Still not convinced? http://bit.ly/pwa-talk
Still not convinced? http://bit.ly/pwa-talk
Progressive Web Apps
Progressive Web Apps PWA & Ember
PWA & Ember “Ember’s size disqualifies it for mobile use”
PWA & Ember EmberConf 2016: “Instant Web Apps”
PWA & Ember
PWA & Ember FastBoot
PWA & Ember FastBoot Svelte Builds
PWA & Ember FastBoot Svelte Builds Engines
PWA & Ember FastBoot Svelte Builds Engines Service Workers
PWA & Ember Image from: EmberCamp 2016 Keynote by Yehuda
Katz & Tom Dale
PWA & Ember Image from: EmberCamp 2016 Keynote by Yehuda
Katz & Tom Dale
PWA & Ember Deliver the raw HTML content by server-side
rendering with FastBoot Image from: EmberCamp 2016 Keynote by Yehuda Katz & Tom Dale
Image from: EmberCamp 2016 Keynote by Yehuda Katz & Tom
Dale PWA & Ember Load the minimum amount of JS needed by eliminating dead code and deferring to lazy-loading engines
PWA & Ember A Service Worker makes the application rely
less on the network by pre-loading frequently-used data and assets Image from: EmberCamp 2016 Keynote by Yehuda Katz & Tom Dale
make css, js, fonts and logo images offline first on
install make images and other assets offline first on demand use IndexedDB as fallback for the API PWA & Ember
Progressive Web Apps PWA & Ember Serv•ice Work•er (sûrˈvĭs wûrˈkər)
Serv•ice Work•er (sûrˈvĭs wûrˈkər)
Serv•ice Work•er (sûrˈvĭs wûrˈkər)
An event-driven Web Worker, which responds to events dispatched from
documents and other sources Serv•ice Work•er (sûrˈvĭs wûrˈkər)
Not attached to a particular document, instead it is registered
to an origin and a scope Serv•ice Work•er (sûrˈvĭs wûrˈkər)
Only active while handling events, assume the browser kills it
until the next event happens Serv•ice Work•er (sûrˈvĭs wûrˈkər)
Serv•ice Work•er (sûrˈvĭs wûrˈkər) Lifecycle events
Serv•ice Work•er (sûrˈvĭs wûrˈkər) Lifecycle events Functional Events
Serv•ice Work•er (sûrˈvĭs wûrˈkər) Lifecycle events Functional Events Install
Serv•ice Work•er (sûrˈvĭs wûrˈkər) Lifecycle events Functional Events Install Activate
Serv•ice Work•er (sûrˈvĭs wûrˈkər) Lifecycle events Functional Events Install Activate
Fetch
Serv•ice Work•er (sûrˈvĭs wûrˈkər) Lifecycle events Functional Events Install Activate
Fetch Message
Serv•ice Work•er (sûrˈvĭs wûrˈkər) Lifecycle events Functional Events Install Activate
Fetch Message Push
Serv•ice Work•er (sûrˈvĭs wûrˈkər) Lifecycle events Functional Events Install Activate
Fetch Message Push Sync
None
None
None
Serv•ice Work•er (sûrˈvĭs wûrˈkər)
None
Register Origin dockyard.com Scope / sw.js
Install app.js app.css index.html Cache
Activate claim documents cleanup caches ask for permissions
Fetch
Fetch doug.jpg
Fetch doug.jpg
Fetch doug.jpg
Fetch doug.jpg
None
None
None
None
None
None
Push
Push
Sync
Sync
Sync
Sync
Sync
Sync
Sync
Progressive Web Apps PWA & Ember Serv•ice Work•er (sûrˈvĭs wûrˈkər)
Progressive Web Apps a Service Worker ➡ Ember PWA &
Ember Serv•ice Work•er (sûrˈvĭs wûrˈkər)
B.Y.O. Build your own
public/sw.js if ('serviceWorker' in navigator) { navigator.serviceWorker.register(‘/sw.js’); } app/index.html
No ES6+, Modules, Minification
ember-cli-build.js
ember-cli-build.js
ember-cli-build.js plugin
Awww yeah!
Awww yeah!
Awww yeah! You just wasted someone’s money
Awww yeah! You just wasted someone’s money
Re-solving well-solved, common problems is a waste of resources.
Re-solving well-solved, common problems is a waste of resources. -
Edward Faulkner
Re-solving well-solved, common problems is a waste of resources. -
Edward Faulkner https://github.com/emberjs/rfcs/pull/143
Don't waste time making trivial choices. Ember.js incorporates common idioms
so you can focus on what makes your app special, not reinventing the wheel. http://emberjs.com
Shared solutions
Shared solutions
Shared solutions
Shared solutions
Shared solutions
Shared solutions
Broccoli Service Worker
Broccoli Service Worker
Broccoli Service Worker
None
Great solution, but not flexible enough Broccoli Service Worker
Shared Solution Pyramid of Flexibility
Shared Solution Pyramid of Flexibility common boilerplate
Shared Solution Pyramid of Flexibility common boilerplate common use cases
Shared Solution Pyramid of Flexibility common boilerplate common use cases
custom code
Shared Solution Pyramid of Flexibility common use cases custom code
ember
Shared Solution Pyramid of Flexibility custom code ember addon addon
addon
Ember Service Worker Introducing:
A pluggable approach to Service Workers
Ember Service Worker common boilerplate common use cases custom code
Ember Service Worker service worker compilation and registration common use
cases custom code
Ember Service Worker Common Boilerplate
Ember Service Worker Common Boilerplate Discover all Service Worker plugins
Ember Service Worker Common Boilerplate Discover all Service Worker plugins
Compile all SW code into one file using Babel and Rollup
Ember Service Worker Common Boilerplate Discover all Service Worker plugins
Compile all SW code into one file using Babel and Rollup Compile the SW registration code, w Babel and Rollup
Ember Service Worker Common Boilerplate Injects Service Worker Registration into
index.html Discover all Service Worker plugins Compile all SW code into one file using Babel and Rollup Compile the SW registration code, w Babel and Rollup
None
Ember Service Worker service worker compilation and registration common use
cases custom code
Ember Service Worker service worker compilation and registration plugin plugin
plugin custom code
Ember Service Worker Plugin Examples
Ember Service Worker Plugin Examples Offline first assets
Ember Service Worker Plugin Examples Offline first assets Push notifications
Ember Service Worker Plugin Examples Offline first assets Offline first
API with background sync Push notifications
Ember Service Worker Plugin Examples Offline first assets Offline first
API with background sync Push notifications Asset Diff Patching
Offline first API with background sync
Offline first API with background sync
Offline first API with background sync
Offline first API with background sync
Synchronization? Offline first API with background sync
Service Worker! Offline first API with background sync
Ember Service Worker service worker compilation and registration plugin plugin
plugin custom code
None
None
Ember Service Worker service worker compilation and registration plugin plugin
plugin custom code
/service-worker Ember Service Worker
/service-worker index.js Ember Service Worker
Prediction
Prediction The plugin ecosystem will cover 90% of the use-cases
with little to no configuration.
Prediction The plugin ecosystem will cover 90% of the use-cases
with little to no configuration. The other 10% can be achieved by writing custom code or building private plugins.
None
Working with Service Workers exposes you to cache invalidation problems.
You should thoroughly test before deploying to production.
The code isn't backed by a decent automated test- suite
yet, this is because testing Service Workers is a new problem, that hasn't been done or documented that much.
The addon has not been widely tested yet, please install
the addon and test it on your staging deploys and report issues.
None
None
None
Have at least a production ready solution before Safari ships
Service Workers
None