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
Natura Meet Up PWA - Offline first
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Marcus Ortense
September 12, 2019
Programming
88
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Natura Meet Up PWA - Offline first
Marcus Ortense
September 12, 2019
Transcript
34 slides
– OFFLINE FIRST meetup
Chapter Manager @ Concrete
Tech Lead @ Social Selling
– OFFLINE FIRST meetup Por que isso é importante?
– Qual a realidade da internet hoje?
– 40% dos usuários abandonam o site após 3 segundos
de espera. fonte: Dynatrace / Gomez.com (http://bit.ly/29jzPRc)
– Amazon identificou que cada 100 milissegundos de espera representa
a queda de 1% nas vendas fonte: Amazon / Findory (http://bit.ly/2kd4UOp)
– Em 2019 a cobertura de 3G no Brasil chegou
a 97.6%, atingindo 5438 municípios. fonte: Operadoras (http://bit.ly/2kaUSNC)
– 33% dos brasileiros acessa a internet apenas por dispositivos
móveis fonte: IBGE (http://bit.ly/2k8rFTs)
– 76% dos brasileiros utiliza banda larga móvel, sendo que
17% não possui acesso a outro tipo de conexão. fonte: IBGE (http://bit.ly/2k8rFTs)
– Brasil ocupa a 50ª posição no ranking de velocidade
de internet móvel. fonte: IBGE (http://bit.ly/2k8rFTs)
– A média de velocidade de internet móvel no Brasil
é 13mbs, abaixo da média global de 17mbs. fonte: IBGE (http://bit.ly/2k8rFTs)
– Mais de 70% dos acessos ao rede vem de
dispositivos móveis. fonte: Rede Natura
– E o que isso tem a ver com PWA?
None
None
None
– Progressive Web Apps é uma experiência do usuário ao
alcance da web confiável, rápida e engajante. fonte: Google Developers (http://bit.ly/2kI5J1J)
– Progressive Web Apps é uma experiência do usuário ao
alcance da web confiável, rápida e engajante. fonte: Google Developers (http://bit.ly/2kI5J1J)
– Carregue instantaneamente e nunca mostre o downasaur, mesmo em
condições de rede incertas. fonte: Google Developers (http://bit.ly/2kI5J1J)
– Mas como?!
– Tipo de conexão console.log(navigator.connection) NetworkInformation { downlink: 10, //
Estimativa da banda em MB/S effectiveType: '4g', // Tipo de conexão slow-2g, 2g, 3g', or 4g rtt: 0, // round-trip time em milissegundo saveData: false, // O usuário utiliza economia de dados onchange: null, // Event Handler }
– Online/Offline window.addEventListener('online', (e) => console.log('Online ')); window.addEventListener('offline', (e) =>
console.log('Offline ')); if(window.navigator.onLine) { console.log('Online ') } else { console.log('Offline ') }
– Service Workers INSTALL ACTIVATED ERROR IDLE TERMINATED FETCH /
MESSAGE fonte: Google Developers | Web Fundamentals (http://bit.ly/2kxftft)
if('serviceWorker' in navigator) { console.log('ServiceWorker é suportado neste navegador ')
} else { console.log('ServiceWorker não é suportado ') }
navigator.serviceWorker.register('assets/sw.js') .then(reg => console.info('registered ', reg)) .catch(err => console.error('error registering
', err))
navigator.serviceWorker.register('assets/sw.js') .then((reg) => { if(reg.installing) { console.log('Instalando ') } else
if(reg.waiting) { console.log('Instalado ✅') } else if(reg.active) { console.log('SeviceWorker ativo ') } })
navigator.serviceWorker.register('assets/sw.js') .then((reg) => { const sw = reg.installing reg.addEventListener('updatefound', ()
=> { sw.addEventListener('statechange', () => { console.log(`Status atualizado para ${sw.state} `) }) }) })
const PRE_CACHE_URL = [ '/index.html', '/styles/main.css', '/script/main.js' ]; self.addEventListener('install', (event)
=> { event.waitUntil(caches.open('cache-app-v1') .then((cache) => cache.addAll(PRE_CACHE_URL))) })
self.addEventListener('fetch', (event) => { event.respondWith( caches.match(event.request).then((response) => { if(response) return
response return fetch(event.request) }) ) })
event.respondWith( caches.match(event.request).then((response) => { if(response) return response return fetch(event.request) .then(response
=> { caches.open('cache-app-v1').then(cache => cache.put(event.request, response.clone())) return response }) }) .catch(() => caches.match('fallback.html')))
– CONCLUSÃO
– Offline first é possível, faz sentido, pode ser feito
hoje e cria uma a experiência mais confiável para o seu usuário.
OBRIGADO! @marcusortense
[email protected]
bit.ly/2kypFEv
More Decks by Marcus Ortense
See All by Marcus Ortense
Analytics para Devs
ortense
1
110
Concrete on Beer JavaScript - Offline first
ortense
0
140
Escrevendo javascript testável
ortense
1
170
Serverless
ortense
0
93
Talk - let, const & arrow functions
ortense
0
78
Talk - JavaScript Isomórfico
ortense
0
94
Desenvolvimento vs Conversão
ortense
2
120
Other Decks in Programming
See All in Programming
AI時代のFlutter品質設計 — アプリ品質を守るQuality Layers
omatty198
0
390
ビジネスロジックを堅牢に~Scala 3のドメインプリミティブ~
j5ik2o
0
230
AIがコードを書いてくれる時代、我々は何を確かめるのか
yosuke_furukawa
PRO
13
6.2k
Beyond Chatbots: Agentic UI with Open Standards @W-JAX 2026, München
manfredsteyer
PRO
0
130
地方こそサーバーレス — 10年続けた、顔が見えるチームで確かな基盤を / Serverless Matters Most in Regional Areas — 10 Years of Building Reliable Foundations with Close-Knit Teams
seike460
PRO
2
520
protojson における文字化けの扱い
kazuki1023
0
460
数行の変更でDockerビルドを最大91%高速化~GitLab CIの実行基盤を社内40リポジトリに展開するまで~
picopico
3
340
Kawaiicon: Kubernetes, it's no longer cool, but let's secure it anyway!
barnbarn
0
150
TS 7.0 で baseUrl が使えなくなった今、パスエイリアスをどうするか
bicstone
2
820
クラウドエージェントは、 何がそんなに便利なのか / what makes cloud agents so useful
rkaga
5
980
Engineering Biometric UX Across Android Versions | DroidKnights 2026
ryunen344
1
220
AIが生成したコードは読むべきか?抽象化設計とコードの品質保証 / abstraction-design-and-quality
minodriven
17
9.5k
Featured
See All Featured
GitHub's CSS Performance
jonrohan
1033
470k
RailsConf 2023
tenderlove
30
1.6k
The SEO Collaboration Effect
kristinabergwall1
1
630
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.7k
SEO for Brand Visibility & Recognition
aleyda
0
4.9k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
500
How to make the Groovebox
asonas
2
2.6k
ラッコキーワード サービス紹介資料
rakko
5
6M
Web Performance Is a Journey [PerfNow 2026]
tammyeverts
2
150
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
680
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
610