Upgrade to Pro — share decks privately, control downloads, hide ads and more …

そろそろ真面目に
Webフロントエンド開発をやる

Yosuke Onoue
January 14, 2017

 そろそろ真面目に
Webフロントエンド開発をやる

Yosuke Onoue

January 14, 2017
Tweet

More Decks by Yosuke Onoue

Other Decks in Technology

Transcript

  1. ࣗݾ঺հ • ͓ͷ͏͑ (@_likr) • ژ౎େֶ ֶࡍ༥߹༥߹ڭҭݚڀਪਐηϯλʔ
 ੓ࡦͷͨΊͷՊֶϢχοτ ಛఆॿڭ •

    ng-kyotoΦʔΨφΠβʔ • ՄࢹԽͷݚڀͱ͔΍ͬͯΔ • ͭͬͨ͘ https://egrid.jp/ • ࠓ೥ͷ໨ඪɿϚαΧϦΛ౤͛ͳ͍
  2. ྑ͍WebαΠτͷࢦ਑ • Progressive Web App Checklist • https://developers.google.com/web/progressive- web-apps/checklist •

    ϕʔεϥΠϯ • HTTPSɺϨεϙϯγϒɺΦϑϥΠϯɺϗʔϜը໘௥ Ճɺ௿଎ճઢରԠɺΫϩεϒϥ΢βରԠɺεϜʔζͳ ϖʔδભҠɺϖʔδຖͷURL • ໛ൣత • ΠϯσοΫεՄೳɺUXɺύϑΥʔϚϯεɺ௨஌
  3. SPAͷಘҙɾෆಘҙ 41"ඇ41"
 ͲͬͪͰ΋΍Δ 41"͕ಘҙ 41"͕ۤख )5514
 Ϩεϙϯγϒ ϗʔϜը໘௥Ճ ௿଎ճઢରԠ Ϋϩεϒϥ΢βରԠ

    ϖʔδຖͷ63- 69 ύϑΥʔϚϯε ௨஌ ΦϑϥΠϯ
 εϜʔζͳϖʔδભҠ ΠϯσοΫεՄೳ
 4&0ɺ0(1ରԠ
  4. PWAͰͰ͖Δ͜ͱ • ΦϑϥΠϯԽ • Πϯλʔωοτ઀ଓͳ͠Ͱͷར༻ • දࣔͷߴ଎Խ • Push௨஌ •

    ΞϓϦ΁ͷ࠶๚Λଅਐ • App Install Banner • ϗʔϜը໘΁ͷγϣʔτΧοτ௥Ճ • ঃʑʹΞϓϦͷΑ͏ʹͳΔʂ
  5. Service Worker • Webϖʔδ(ϝΠϯεϨουɺUIεϨου)ͱ͸
 ಠཱͯ͠εΫϦϓτΛಈ࡞ͤ͞Δ࢓૊Έ • ωοτϫʔΫϦΫΤετΛϑοΫ • ΩϟογϡΛ࢖ͬͯϨεϙϯε •

    ϦΫΤετΛमਖ਼ • αʔόʔPushΛड͚ͯ௨஌Λදࣔ • postMessageͰϝΠϯεϨουͱ௨৴ • HTTPSͰͷΈಈ࡞ (localhostΛআ͘)
  6. ͳͥΦϑϥΠϯWebΞϓϦʁ • ϞόΠϧ؀ڥ΁ͷରԠ • ௨৴ͷෆ҆ఆ͞ • ௨৴ͷޮ཰Խ • ޫ଎౓͸ෆมʂ(໿30ສkm/s) •

    Ր੕ͱ஍ٿͰ௨৴ͨ͠Βʁ (࠷઀ۙ࣌໿7500ສkm) • ΦϑϥΠϯɾϑΝʔετͷࢥ૝ͱ࣮ફ by നੴढ़ฏ
 http://www.slideshare.net/shumpei/thought-and- practice-of-offline-first
  7. sw—precache-webpack-plugin const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin') module.exports = { plugins: [

    new SWPrecacheWebpackPlugin({ maximumFileSizeToCacheInBytes: 10000000, staticFileGlobs: [ 'public/index.html', 'public/bundle.js', 'public/manifest.json' ], stripPrefix: 'public/', navigateFallback: '/index.html', runtimeCaching: [ { urlPattern: /https:\/\/public-api\.wordpress\.com\/rest\/v1\.1\/sites\/ylikr\. handler: 'networkFirst', options: { cache: { name: 'posts' } } } ] }) ] }
  8. HTTPS • HTTP௨৴ΛSSL/TLSͰ҉߸Խ • ηΩϡΞͳWeb΁ • HTTP/2ɺServiceWorkerʹඞཁ • Let’s Encrypt

    • ແྉͷSSL/TLSূ໌ॻ • MozillaΒ͕εϙϯαʔ • FirebaseͰϗεςΟϯά
  9. Rail Performance Model • https://developers.google.com/web/fundamentals/ performance/rail • Response • Ϣʔβૢ࡞ʹରͯ͠100msҎ಺ʹԠ౴

    • Animation • 10ms / ϑϨʔϜ • Idle • ΞΠυϧ࣌ؒΛ௕͘͢Δ • Loading • 1000msҎ಺ʹॳظը໘දࣔ
  10. Rail Performance Model • https://developers.google.com/web/fundamentals/ performance/rail • Response • Ϣʔβૢ࡞ʹରͯ͠100msҎ಺ʹԠ౴

    • Animation • 10ms / ϑϨʔϜ • Idle • ΞΠυϧ࣌ؒΛ௕͘͢Δ • Loading • 1000msҎ಺ʹॳظը໘දࣔ
  11. bundleαΠζΛখ͘͢͞Δ • bundle෼ׂ • ڞ௨෦෼ + ϖʔδຖ • ϥΠϒϥϦ֎෦Խ •

    scriptλάͰಡΈࠐΜͩεΫϦϓτΛ
 CommonJSελΠϧͰ࢖༻͢Δ • CDNར༻ module.exports = { externals: { 'react': 'React', 'react-dom': 'ReactDOM', 'react-router': 'ReactRouter' } } <script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.3.2/react.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.3.2/react-dom.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/react-router/2.8.1/ReactRouter.min.js"></script>
  12. WebαΠτͷछྨͱߋ৽ස౓ • ੩తWebαΠτɺݸਓπʔϧɺήʔϜ • ΞϓϦ = ίϯςϯπ • ։ൃऀ͕ίϯςϯπΛߋ৽ •

    CMSɺϒϩά • ΞϓϦͱίϯςϯπͷ෼཭ • ؅ཧऀ͕ίϯςϯπΛߋ৽ • SNSɺϢʔβࢀՃίϯςϯπ • Ϣʔβ͕ίϯςϯπΛߋ৽ SPAͰΠϯσοΫεՄೳ
 (ϖʔδຖͷมߋ͸ෆՄ) Ϋϩʔϥରࡦ͕ඞཁ ΦϑϥΠϯԽͷ޻෉͕ඞཁ
  13. Ϋϩʔϥରࡦ • Server Side Rendering • ॳظඳըΛαʔόଆͰॲཧ • ॳظϩʔσΟϯάͷߴ଎Խ •

    UniversalΛҙࣝͨ͠ίʔσΟϯά • ϓϦϨϯμϦϯά • Ϋϩʔϥʹରͯ͠ϨϯμϦϯάࡁΈͷHTMLΛԠ౴ • Ϣʔβʹ͸௨ৗͷSPAͱͯ͠ಈ࡞ • ϓϦϨϯμϦϯάͷͨΊͷϛυϧ΢ΣΞ͕ඞཁ
  14. Prerender.io • https://prerender.io/ • PhantomJSͰϓϦϨϯμϦϯά • Headless WebKit • ϛυϧ΢ΣΞ

    • Ϋϩʔϥ͔Ͳ͏͔Λ൑அ͠ϓϦϨϯμϦϯάͱ
 ௨ৗͷϨεϙϯεʹৼΓ෼͚Δ • nginxɺapacheɺexpressɺrails • 250ϖʔδ·Ͱ͸ແྉ
  15. γεςϜߏ੒ • ϑϩϯτΤϯυ • ReactɺReact Helmet • ServiceWorkerɺAppManifest • όοΫΤϯυ

    • wordpress.com API • ͘͞ΒVPS • nginx • hosting • prerender.io • Let’s Encrypt