Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Building a PWA - For Everyone Who Is Scared To

450 views

Published on

My slides for my introductory PWA (progressive web app) talk.

Published in: Technology
  • Be the first to comment

Building a PWA - For Everyone Who Is Scared To

  1. 1. BUILDING A PWA F O R E V E R Y O N E W H O I S S C A R E D TO. . .
  2. 2. FOOD TIPS
  3. 3. DO EAT GUMBO • Chicken and Sausage • Seafood
  4. 4. EAT BOUDIN!
  5. 5. DON’T GOOGLE BOUDIN!
  6. 6. JUST EAT IT! T R U S T M E !
  7. 7. RAYMOND CAMDEN • Senior Developer Advocate for Auth0 Extend • Auth0 Extend, serverless, web and Enterprise Cat demos • Blogging at raymondcamden.com • Tweeting at @raymondcamden
  8. 8. THE PLAN • Cover the basics of PWAs • Show an example • Do this in <50 minutes
  9. 9. THE GUIDE • By: Tal Ater • http://shop.oreilly.com/product/06 36920052067.do
  10. 10. WHAT THE HECK IS PWA? Progressive Web App
  11. 11. OK - BUT *WHAT* IS IT? • A term • Coined by Frances Berriman and Alex Russell in 2015 • Set of Guidelines • Technical Baseline
  12. 12. GUIDELINES • Progressive • Responsive • Works offline, or in poor network conditions • App-like • Fresh • Safe • Discoverable • Re-engageable • Installable • Linkable Source: https://en.wikipedia.org/wiki/Progressive_web_app
  13. 13. THE TECH STACK • Manifest • Service Workers • App Shell
  14. 14. MANIFEST • "Web App Manifest" • Just a JSON file (woot!) • Allows for "installable" web apps • Controls behavior when launched
  15. 15. MANIFEST • The name (as it appears in the shortcut) • Icons (of various sizes) • Splash screen and colors (bg and toolbar) • Chrome • Forced Orientation • The starting URL (handy for passing a param to note the launch) – https://(something)/index.html?utm_source=homescreen
  16. 16. ADDING TO HTML • <link rel="manifest" href="/manifest.json">
  17. 17. SAMPLE
  18. 18. DEMO • Show manifest1 and 2
  19. 19. (AUTO) ADD TO HOME • AKA Web Install Banners • *Current* criteria is: – manifest with short_name, name, 192x192 icon (png only), start_url – service worker – https – "Meets a site engagement heuristic defined by Chrome (this is regularly being changed)." • Event is fired: beforeinstallprompt • Details: https://developers.google.com/web/fundamentals/app-install-banners/
  20. 20. OLD SCHOOL ADD TO HOMESCREEN
  21. 21. WHAT IT LOOKS LIKE
  22. 22. THANKS IOS • Doesn't support manifest :( • But you can configure... • https://developer.apple.com/library/content/doc umentation/AppleApplications/Reference/Safari WebContent/ConfiguringWebApplications/Confi guringWebApplications.html
  23. 23. SERVICE WORKERS
  24. 24. SERVICE WORKERS - INTRO • JavaScript • A script registered via a script • Now - forget everything you know about <script>
  25. 25. "REGULAR" JS • You load foo.html • foo.html is all like <script src="ftw_js_is_awesome_unicorns.js"></script> • Code executes while the tab (window) is "alive" • Close the tab and ftw_js_is_awesome_unicorns.js goes bye bye
  26. 26. SERVICE WORKER JS • Runs in parallel to pages in it's scope • Can't actually do anything the first time it loads • Can run when you're not even on the page • Can intercept every single network request (to be clear, not just XHR) • Can work with the browser cache • Can fire off notifications while you're away (and you totally won't abuse this) • Can respond to push notifications (and you totally won't abuse this) • Can help you sync data • Can't touch the DOM
  27. 27. MORE SERVICE WORKER • You can (and must) check for support • Requires https, but localhost is ok • They have a life cycle • Devtools will be very, very helpful
  28. 28. INSTALLING THE SW
  29. 29. DEMO • Show sw1, debugging
  30. 30. CACHING! • CacheStorage API (LINK) • Keyed by name (this is how you version) • Ability to add one or multiple URLs • Ability to read from the cache (and delete)
  31. 31. EXAMPLE Source: https://developers.google.com/web/fundamentals/primers/service-workers
  32. 32. EXAMPLE Source: https://developers.google.com/web/fundamentals/primers/service-workers
  33. 33. DEMO • Show sw2 (just fetch handler) and sw3
  34. 34. EXCEPT... • You want to change a file • You only want to use the cache if offline • You want some mix of things where you use the cache first then network but then sometimes you want to hit the network first and then cache and oh yeah maybe you want to use the cache and that's cool but maybe you want to hit the network in the background and passively update stuff and oh my god does this end?
  35. 35. GOOD NEWS/BAD NEWS • Good News: Caching Strategies exist • Bad News: You're responsible for figuring it out • See "The Offline Cookbook" - https://developers.google.com/web/fundamentals/instant-and-offline/offline- cookbook/
  36. 36. EXCEPT ROUND TWO... • iOS - no support for Service Workers • But officially "in development" for WebKit • AppCache
  37. 37. BACKGROUND SYNC • Another ServiceWorker feature • App js tells SW js - "hey, start syncing Foo" • SW says - "Ok, no problem. I'll get around to it." • SW will try to do Foo (you write the logic) • If it fails, it will try again (and again...) • Finally, it will try one last time and *tell* you as well • https://developers.google.com/web/updates/2015/12/background-sync
  38. 38. EXAMPLE
  39. 39. EXAMPLE
  40. 40. PUSH NOTIFICATIONS • Two APIs - Push and Notification • Notification - https://developer.mozilla.org/en-US/docs/Web/API/notification • Request permission to show a notification • You can show it
  41. 41. EXAMPLE
  42. 42. NOTIFICATIONS
  43. 43. NOTIFICATIONS
  44. 44. PUSH • User subscribes to push messaging (two step process) • Your server sends a message to central Message server • Messaging server talks to Service Worker • Service Worker does whatever (probably Notification)
  45. 45. THANKS APPLE! • https://developer.apple.com/notifications/safari-push-notifications/
  46. 46. EXAMPLE (MINUS 99%)
  47. 47. STUFF I DIDN'T COVER • ServiceWorker to browser communication • Client-side storage
  48. 48. RESOURCES • https://developer.mozilla.org/en-US/Apps/Progressive • https://developers.google.com/web/progressive-web-apps/ • https://jakearchibald.github.io/isserviceworkerready/ • https://developers.google.com/web/tools/lighthouse/ • https://pwastats.com • https://pwa.rocks/
  49. 49. LIGHTHOUSE
  50. 50. JUST BUY THIS
  51. 51. LAST DEMO C O N F E R E N C E S
  52. 52. CONFERENCE "APPS" • Web, not native • Because - duh • No marketing, just text • Works offline • That's it.
  53. 53. H T T P S : / / C F J E D I M A S T E R . G I T H U B . I O / I C E C O N F D E M O / T H E M O S T AW E S O M E D E M O E V E R
  54. 54. SO – ABOUT THE APPLE IN THE ROOM...
  55. 55. SAFARI AND PWAS • Supported in betas for macOS (really, we’re calling it this now?) and iOS • Service Workers (Caching) and App Manifests • No Push or Sync • And it gets better: https://medium.com/@firt/pwas-are-coming-to-ios-11-3-cupertino- we-have-a-problem-2ff49fd7d6ea
  56. 56. ANY QUESTIONS? • Email me at raymondcamden@gmail.com • Visit my awesome blog at raymondcamden.com • Follow my awesome Twitter account at @raymondcamden

×