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
Progressive Web Apps with React.js in a nutshel...
Search
Jimmy Moon
May 20, 2016
0
57
Progressive Web Apps with React.js in a nutshell at Google I/O devfest 2016
Progressive Web Apps with React.js in a nutshell at Google I/O devfest 2016
Jimmy Moon
May 20, 2016
Tweet
Share
More Decks by Jimmy Moon
See All by Jimmy Moon
Edge Computing for WebApp
ragingwind
0
85
Micro-Saas for developer who want a new
ragingwind
0
68
How to use The Fourth Language
ragingwind
0
170
Please Use The Fourth Language - WebAssembly
ragingwind
0
150
Head topics in Javascript, 2020
ragingwind
1
640
Recap Modern WebAssembly in CDS 2019
ragingwind
0
270
Today headlines in Javascript, 2019
ragingwind
0
460
Today, The Actions in Javascript
ragingwind
2
760
PWA Updates in Chrome 68
ragingwind
0
180
Featured
See All Featured
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Designing Experiences People Love
moore
138
23k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
247
1.3M
Why Our Code Smells
bkeepers
PRO
335
57k
Imperfection Machines: The Place of Print at Facebook
scottboms
266
13k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
48
2.2k
Writing Fast Ruby
sferik
628
61k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
510
A designer walks into a library…
pauljervisheath
204
24k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Visualization
eitanlees
146
15k
Transcript
Progressive Web Apps with React.js in a Nutshell
Progressive Web Apps with React.js in a Nutshell https://medium.com/@addyosmani
https://medium.com/@addyosmani - Part 1 - Introduction - Part 2 -
Page Load Performance - Part 3 - Offline support and network resilience - Part 4 - Progressive Enhancement
Github / NPM +JimmyMoon @ragingwind Google Developer Expert
Part 1 - Introduction for Progressive Web Apps
https://react-hn.appspot.com
ȍȇȇ app.yaml ȍȇȇ dist ȍȇȇ hn-server-fetch.js: unofficial hn APIs ȍȇȇ
nwb.config.js: nwb config ȍȇȇ package.json ȍȇȇ public Ȉ ȍȇȇ index-static.html Ȉ ȍȇȇ manifest.json Ȉ ȍȇȇ runtime-caching.js Ȉ Ȍȇȇ service-worker.js ȍȇȇ server.js ȍȇȇ src Ȉ ȍȇȇ App.js: App and Components Ȉ ȍȇȇ Comment.js Ȉ ȍȇȇ Item.js Ȉ ȍȇȇ NotFound.js Ȉ ȍȇȇ PermalinkedComment.js Ȉ ȍȇȇ Settings.js Ȉ ȍȇȇ Updates.js Ȉ ȍȇȇ UserProfile.js Ȉ ȍȇȇ index.js Ȉ ȍȇȇ routes.js Ȉ ȍȇȇ services: fetch APIs Ȉ ȍȇȇ stores: cache, store data Ȉ ȍȇȇ utils Ȉ Ȍȇȇ views: template Ȍȇȇ sw-precache-config.json - React.js ӝࠄੋ ࣗझ ܻ - nwb ਸ ࢎਊೞৈ ۽ં ࢤࢿ/ҙܻ - editing nwb.config.js - HackerHN Firebase APIs ࢎਊ
- ୡࠁ ѐ֛ ӝਊ - React.js ୭न ߡ - Webpack
2 - Code-spliting - Tree-shaking - Commonchunk - and More - PRPL ಁఢ ਊ - Service Worker పझ ਗ - ݒఠܻ ٣ੋ with React MDL - рױೠ ҳઑ৬ ࠭ https://github.com/ ragingwind/bare-react-pwa
https://github.com/GoogleChrome/lighthouse - ֎ਖ োѾ উ - Add to Home screen
ࢎਊ оמ ৈࠗ - Custom splash screen ࢎਊ оמ ৈࠗ - য়ۄੋա ৌঈೠ ֎ਖ ജ҃ী ز оמ ৈࠗ - ಕ ۽٘ ࢿמ যځೠ - ݽ߄ੌ-۪ٜܻ ٣ੋਸ ࢎਊ೮ח - Progressively enhanced ܳ ਗೞח জ ੋ - ࣗହ ࢝җ ੜ ݒ غח Lighthouse Auditing tools for Progressive Web App
Ready for Mobile Platform - ઁח ݽ߄ੌ ۖಬ ୭ࢶ ఋ
ۖ ಬ - ݽ߄ੌ ജ҃ী ೠ JS Libraries/ Frameworks ࢎਊೞ - preact - AngularJS 2 Mobile - पઁ ݽ߄ੌജ҃ա ਬࢎജ҃ীࢲ పझ ೞ - Remote Debugging Android Devices - WebPagetest
HTTPS Network connection is secure - ӝઓ HTTP ࢚ ೧ఊ
߂ উࢿ ࠁ৮ - Service Worker/Push Notification ܳ ࢎਊೞৈ ࢎਊо જইೞח জਸ ٜ݅ӝ ਤ೧ࢲ - അ ޖܐ/о ࣛܖ࣌ ࢎਊоמ - Let's Encrypt - Cloudlare - Google App Engine for Node.js - Github Pages
None
Web App Manifest Add to Home screen - рױೠ JSON
ੌ - ࢸ оמೠ (Installable) ਢজਸ ਤೠ ࢸ ٜ, ܴ, ই١ - Install Banner/Add to Home Screen - Splash Screen - Theme Color
Install Banners - ࢎਊೞח ࢎਊীѱ জਸ рױ ࢸ ೞب۾
ӂਬ - Home Screen ী ١۾ػ জ ҃ ߑ ޙਯ ब ೱ࢚оמ
Splash Screen - ؊࢚ ۽٬ ֢-ച-झܽ Ӓ݅ - ֎౭࠳ জҗ
э ҃ ઁҕ - Chrome, Firefox and Opera supports - Safari have broken in iOS9
http://realfavicongenerator.net/
http://app-manifest.firebaseapp.com/
$ npm install -g pwa-manifest
None
Mobile-Friendly Design - ݽ߄ੌ-ब ٣ੋਸ ೞ݅ … ؘझ ب
݃ࣁਃ - Responsive Web Design - নೠ ೧࢚ب/ࣄٜ ীࢲ ࢎਊ ࠛಞহ ز೧ঠ פ
- meta “viewport” ܳ ࢎਊೞৈ ࠳ۄઉ viewport ܳ ઑೞࣁਃ
None
Part 2 - Page Load Performance
None
Performance Goal - RAIL ಁఢ L(Loading under 1sec) ী ೞࣁਃ
- ֎ਖ ઑѤਸ ղܻҊ ࢎೱ ೞ٘ਝযী ࢲب ࠙ ੜ ز೧ঠפ. - ߑޙदীח 5 ୡ ղ(Speed Index of 3,000 or less) - ߑޙद(with S/W, Speed Index of 1,000 or less)ীח 2 ୡղ জ ࢎਊ ઑী ߈೧ঠפ.
None
None
None
None
None
None
https://twitter.com/samccone/status/771786445015035904
None
None
None
None
Code-splitting by routes - ೞա ੌਸ ۄ ӝ߈ਵ۽ ܻ࠙
- ܲ ۄী ਃೠ ੌٜ റী ߹ ب۽ ۽٬оמ (Lazy-loading) - ୡӝ ۄ ࢿמ ೱ࢚ਵ۽ ࢎਊ ࢎਊо מ दр খѹ
None
monolithic bundles code-splitting by routes
- নೠ Webpack ۞Ӓੋਵ۽ ਊਸ ੌ ࣻ - CommonsChunkPlugin,
п Entrypoint ীࢲ ҕਊਵ۽ ࢎਊغח ܳ ܻ࠙, ࢎਊоמ - Tree Shaking, ؘ٘٘ ઁѢ۽ ਊ য оמ (but Webpack 2) More plugins for Webpack
Preload - ࢶ݅ਵ۽ ܻࣗझ ಁ оמ (प೯হ) - Әөח only
in Chrome
None
Implementing PRPL - Push - HTTP/2 + Server Push -
Preload / Defer load - AggressiveSplittingPlugin - Rendering - ࢎਊೞח JS ۨਕܳ ୭ೠ ഝਊೞࣁਃ - Pre-caching: - sw-precache - SWPrecacheWebpackPlugin - Lazy-load - require.ensure() or System.import()
Cache-busting - ਬפೠ ੌݺਸ ࢎਊೞৈ ܻࣗझܳ ഛ पೞѱ ҙܻೞח ߑߨ
- ٘ ӝ߈ ܻࣗझ ܻࣗझ ҙܻ ߑߨ - ୶оੋ ܴਸ ؊ೞח ߑध - chunk.js?v=1.2.0 - chunk.d9834554decb6a8j.js - ࠂੌ ۽٘ ߑ - ݆ Webpack Plugins ࢎਊоמ
Webpack 2 Tree Shaking - ES2015 ীࢲ ࢎਊ, - Dead
Code (Unused export) ઁѢ
Part 3 - Offline support and network resilience
None
ServiceWoker - Offline-dinosaur ܳ લӝ ਤ೧ࢲ కয լणפ - ߔӒۄ٘
ীࢲ ߹ب۽ ز - ߄ झ݀۽ ۽Ӓې߁ оמ - cache, fetch, sync ਵ۽ ֎ਖ ਃ ઁ য оמ - Push notification ࢎਊ оמ - IndexedDB ࢎਊ оמ - য়ۄੋ ࡺ݅ ইפۄ ࠛউೠ ֎ਖ ജ ҃ীࢲب ୭࢚ জ ҃ ઁҕ
None
None
None
None
None
None
None
None
None
Chrome DevTools for Service Worker - DevTools > Application tab
> Service Workers - 3G throttling and CPU throttling ࢎਊ ೧ࢲ ୭ೠ ࠺तೠ ജ҃ীࢲ పझܳ ӂ
App Shell Architecture - ֎౭࠳ জ(জۨ) җ э ࡅܲ ۽٬
ਸ ࠁৈח ೠо ߑߨ - PWA ীࢲ ઁউೞח ইఃఫ - ୭Ҋೠ HTML, CSS and JavaScript ۽ জ ӝࠄ ҎѺ UI ܳ ҳࢿ - Toolbars, Drawers, Navigation - ࢲ࠺झ ਕழܳ ਊ೧ࢲ ޖઑѤ நए
None
App Shell Caching via Service Worker in low-friction - vanilla.js
ਸ ࢎਊೞӝ - sw-precache / sw-toolbox ࢎਊೞӝ - Webpack ۞Ӓੋ ࢎਊೞӝ - offline-plugin - sw-precache-webpack-plugin - create-react-pwa ۽ ۽ં ࢤࢿ
None
None
config.json
webpack.config.js
Using runtime/dynamic caching with sw-toolbox
None
None
Part 4 - Progressive Enhancement Building Progressively Becoming Apps Alex
Russell - Progressive Web Apps: Escaping Tabs Without Losing Our Soul
None
Universal Rendering - ࢲߡীࢲ ࢤࢿػ ୡӝ HTML ஶబஎܳ ߄ ۽
࣠ - ୡӝ ۪؊݂द ୶о HTML/JS/CSS ੌ Fetching ਸ ઁೠ - React.js / ழޭפ౭ ৌആ ਗ - ReactDOMServer.renderToStrin g() - React Router - isomorphic-fetch
None
Pro React - https://goo.gl/EXRM3k
None
None
None
None
None
Guarding against globals - ࢲߡ Node.js ജ҃ীࢲ زೡ ҃ `document`
ژח `window` ёܳ ഛ ੋೡ ਃо णפ. - ReactDOM but 3rd party ஹನք ࢎ ਊ ਗৈࠗ ഛੋ - Webpack ߣٜ݂द `browser` ః (package.json) ܳ ਊೞৈ JS ੌਸ ܻ࠙೧ࢲ ࢎਊоמ
Remember: Interactivity is key - ਬפߡࢸ ۪؊݂ ߈٘द জ ޖઑѤ
TTI ࢚కо ػח Ѫਸ ೞ ঋणפ . - प೯ী ਃೠ ୭ࣗೠ HTML җ ۄ ী ਃೠ JS/CSS ܳ ࢎਊೞࣁਃ - റী ਃೠ ܻࣗझ৬ ٘ܳ ۽٘ ೧ࢲ ରਵ۽ ӝמਸ ୶о दఃࣁਃ (PRLP ಁఢ)
- JS Based Render: HTML ׳ റ ݆
ੌਸ פ. ݽٚ झ݀ ۽٘ ӒܻҊ य, प೯غযঠ জ प೯ؾפ - Server render + Hydrate / Fastboot: ݽٚ ߄झ݀о ز оמ೧ঠ ৮߷ زפ. (uncanny valley) - Progressive Render: ࣻ زী ਃ ೠ ୭ࣗೠ HTML/JS/CSS ܳ ׳ೞৈ زоמೞѱ ೞҊ റ ରਵ۽ ࠁъ פ
- JS Based Render: HTML ׳ റ ݆
ੌਸ פ. ݽٚ झ݀ ۽٘ ӒܻҊ य, प೯غযঠ জ प೯ؾפ Server render + Hydrate / Fastboot: ݽٚ ߄झ݀о ز оמ೧ঠ ৮߷ زפ. (uncanny valley) - Progressive Render: Sending only functionally viable(minimal) view in the HTML, JS, CSS included, and more resource arrive progressively
- JS Based Render: HTML ׳ റ ݆
ੌਸ פ. ݽٚ झ݀ ۽٘ ӒܻҊ य, प೯غযঠ জ प೯ؾפ Server render + Hydrate / Fastboot: ݽٚ ߄झ݀о ز оמ೧ঠ ৮߷ زפ. (uncanny valley) - Progressive Render: ࣻ زী ਃ ೠ ୭ࣗೠ HTML/JS/CSS ܳ ׳ೞৈ زоמೞѱ ೞҊ റ ରਵ۽ ࠁъ פ
Testing Progressive Enhancement - ୭Ӕ ٣ߡӦ ో ߄झ݀о হח ҃
, ֎ਖ ജ҃ જ ঋ ҃ܳ दޯ ۨ оמפ.
http://slack.gdg.kr/ /join #pwa
Fin