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

🇮🇨 JSDay Canarias 2023

🇮🇨 JSDay Canarias 2023

ℹ️ Hydration, Islands, Streaming, Resumability… Oh My!

Our ecosystem can be overwhelming! First, we had the rise of SSR and SSG—and each had its own gigantic pile of frameworks and tools. Then partial hydration enabled us to hydrate only some of our components on the client, which we've seen in React Server Components.

But what about islands? Do they relate at all to Streaming SSR? Moreover, what is resumability, and why do I keep hearing about it? […] Oh, did anyone say rendering on the Edge?

Well… There are many approaches out there, and all of them argue that their philosophy is best. In this session, we’ll go over these architecture/rendering patterns, to help shed some light on how some are implemented and the concepts behind them.

Matheus Albuquerque

May 27, 2023
Tweet

More Decks by Matheus Albuquerque

Other Decks in Programming

Transcript

  1. HYDRATION, ISLANDS, STREAMING, RESUMABILITY… OH MY! • THE 27TH OF

    MAY, 2023. Hello, JSDay Canarias 👋 🇮🇨
  2. HYDRATION, ISLANDS, STREAMING, RESUMABILITY… OH MY! ↑ ALL THE LINKS!

    🤓 🧑🏫 @techlabs 🐦 @ythecombinator 👨💻 @medallia ⚡ Perf GDE
  3. #disclaimer 😌 This is for those who like to see

    what’s behind the curtain. You don’t have to know all of that to be productive with front-end development.
  4. This talk presents… ↝ The Past & The Future ↝

    Islands Architecture ↝ Resumability ↝ Streaming SSR + Selective Hydration ↝ React Server Components ↝ Closing Thoughts
  5. HOW AND WHERE DO I WANT TO RENDER CONTENT? web

    server build server the Edge the client
  6. web server build server the Edge the client all at

    once partially progressively HOW AND WHERE DO I WANT TO RENDER CONTENT?
  7. AND MORE! all at once partially progressively Where do you

    navigate? When do you load? What is executed on load? When is data fetched? What do you bundle/serialize? web server build server the Edge the client
  8. ↝ LANGUAGES LIKE PERL AND PHP ALLOWED DEVELOPERS TO RENDER

    BACKEND DATA SOURCES INTO HTML ↝ DEVELOPERS WERE NOW ABLE TO BUILD DYNAMIC SITES AND SERVE REAL-TIME DATA, OR DATA FROM A DATABASE TO AN END USER CGI SCRIPTING LANGUAGES
  9. ↝ THESE WORKED ON THE SERVER BECAUSE SERVERS WERE THE

    POWERFUL PART OF THE NETWORK ↝ THE BROWSER'S JOB WAS LIMITED: INTERPRETING THE DOCUMENT AND SHOWING THE PAGE ↝ THIS SOLUTION WAS ALL ABOUT SHOWING INFORMATION, NOT INTERACTING WITH IT CGI SCRIPTING LANGUAGES
  10. #eureka 💡 JavaScript and browsers got powerful = we could

    do a ton of fun things directly on the client.
  11. ↝ ONCE EVERYTHING IS IN PLACE, YOU DON’T HAVE TO

    GO BACK TO THE SERVER FOR MORE REQUESTS ↝ YOU CAN CACHE THE CORE HTML AND JS BUNDLES ON A CDN ↝ AS THE WEB GOT MORE INTERACTIVE, CSR AND SPAS BECAME DEFAULT CLIENT-SIDE RENDERING (CSR)
  12. #gotcha 🥸 We now had to be mindful of how

    our apps would render on a phone on a bus in the city center.
  13. #eureka 💡 We now had to be mindful of how

    our apps would render on a phone on a bus in the city center. Back to the server! 🏃
  14. ↝ HTML IS READY TO BE DISPLAYED WHEN THE PAGE

    IS LOADED = HIGHER PERFORMANCE ↝ HTML IS NOT DEPENDENT ON THE END BROWSER = HIGHER COMPATIBILITY ↝ FOR INTERACTIVE WEBSITES, WE STILL NEED TO SEND JS = HYDRATION SERVER-SIDE RENDERING (SSR)
  15. #definition 🧐 Hydration is the process of attaching behavior to

    declarative content to make it interactive. — WHY PROGRESSIVE HYDRATION IS HARDER THAN YOU THINK, BY MIŠKO HEVERY
  16. ↝ ASSOCIATE DOM ELEMENTS WITH THEIR CORRESPONDING EVENT HANDLERS ↝

    ONCE A USER EVENT TRIGGERS A HANDLER, WE NEED TO UPDATE THE APP STATE ↝ ONCE THE APP STATE UPDATES, THE FRAMEWORK NEEDS TO RECREATE THE COMPONENT HIERARCHY HYDRATION: CHALLENGES 🍺
  17. ↝ DO WE SEND ALL JS ON EVERY REQUEST? OR

    DO WE BASE IT ON THE ROUTE? ↝ IS HYDRATION DONE TOP-DOWN? AND HOW EXPENSIVE IS THAT? ↝ HOW DOES THE DEVELOPER ORGANIZE THE CODE BASE? HYDRATION: QUESTIONS 🍺
  18. ↝ SELECTIVELY, PROGRESSIVELY ENHANCING BITS OF SERVER-RENDERED HTML WITH CLIENT-SIDE

    JS ↝ SMALL, FOCUSED, CHUNKS OF INTERACTIVITY WITHIN SERVER-RENDERED WEB PAGES ↝ SINGLE APPLICATION IN CONTROL OF FULL-PAGE RENDERING → MULTIPLE ENTRY POINTS ISLANDS ARCHITECTURE
  19. ↝ THE SCRIPT FOR THE ISLANDS CAN BE DELIVERED AND

    HYDRATED INDEPENDENTLY, ALLOWING THE REST OF THE PAGE TO BE JUST STATIC HTML ↝ THE OUTPUT OF ISLANDS IS PROGRESSIVELY ENHANCED HTML ↝ MORE SPECIFICITY AROUND HOW THE ENHANCEMENT OCCURS ISLANDS ARCHITECTURE
  20. #definition 🧐 Islands are a component-based architecture that suggests a

    compartmentalized view of the page with static and dynamic islands. — ISLANDS ARCHITECTURE, BY PATTERNS.DEV
  21. ISLANDS ARCHITECTURE PAGE LAYOUT (SSR’D) POST TITLE (SSR'D) POST CONTENT

    (SSR’D) COMMENTS PLACEHOLDER (SSR) SOCIAL CTA PLACEHOLDER (SSR) COMMENTS “APP” (SSR’D + HYDRATION SCRIPT) SOCIAL CTA “APP” (SSR’D + HYDRATION SCRIPT)
  22. ISLANDS ARCHITECTURE PAGE LAYOUT (SSR’D) POST TITLE (SSR'D) POST CONTENT

    (SSR’D) COMMENTS PLACEHOLDER (SSR’D) SOCIAL CTA PLACEHOLDER (SSR’D) COMMENTS “APP” (SSR’D + HYDRATION SCRIPT) SOCIAL CTA “APP” (SSR’D + HYDRATION SCRIPT)
  23. ↝ STREAMING RENDERING + AUTOMATIC PARTIAL HYDRATION + COMPILER ↝

    AUTOMATIC PARTIAL HYDRATION ALLOWS INTERACTIVE COMPONENTS TO HYDRATE THEMSELVES ↝ HYDRATION CODE IS ONLY SHIPPED FOR INTERACTIVE COMPONENTS ISLANDS ARCHITECTURE (WITH MARKO) 🍺
  24. ↝ BY DEFAULT, SHIPS ZERO JAVASCRIPT ↝ EVERY ISLAND IS

    LOADED IN PARALLEL ↝ YOU CAN SPECIFY THE LOADING STRATEGY FOR EACH ISLAND INDIVIDUALLY ↝ MULTI-FRAMEWORK: BUILD ISLANDS WITH REACT, PREACT, SVELTE, VUE, AND OTHERS ISLANDS ARCHITECTURE (WITH ASTRO)
  25. - - - import MyReactComponent from ' . . /components/MyReactComponent.jsx';

    - - - <MyReactComponent /> ISLANDS ARCHITECTURE (WITH ASTRO)
  26. - - - import MyReactComponent from ' . . /components/MyReactComponent.jsx';

    - - - <MyComponent client:load /> <MyComponent client:idle /> <MyComponent client:visible /> <MyComponent client:media={string} /> <MyComponent client:only={string} /> ISLANDS ARCHITECTURE (WITH ASTRO)
  27. ↝ STANDALONE/METAFRAMEWORK: Astro, Iles, Qwik, Marko, Nano JSX, Capri ↝

    11TY: is-land, Slinkity ↝ PREACT: Fresh, preact-island, microsite ↝ SOLIDJS: Solid Start, isolid ↝ SVELTE: Elder.js ISLANDS ARCHITECTURE
  28. #case💡 An e-commerce. Product pages have static descriptions and links.

    Interactive components (e.g., image carousels, search bar) are available in different regions.
  29. #case💡 An internet banking app. The account details page contains

    a list of static transactions with filters providing some interactivity.
  30. 🟢 REDUCES THE AMOUNT OF JAVASCRIPT CODE SHIPPED TO THE

    CLIENT 🟢 FASTER PAGE LOADS AND TIME TO INTERACTIVE (TTI) 🟢 KEY CONTENT IS AVAILABLE ALMOST IMMEDIATELY TO THE USER 🟢 STATIC CONTENT IS RENDERED ON THE SERVER = PAGES ARE SEO-FRIENDLY GREAT 🟡 HIGHLY INTERACTIVE PAGES WOULD PROBABLY REQUIRE THOUSANDS OF ISLANDS NOT GREAT ISLANDS ARCHITECTURE
  31. 🟢 REDUCES THE AMOUNT OF JAVASCRIPT CODE SHIPPED TO THE

    CLIENT 🟢 FASTER PAGE LOADS AND TIME TO INTERACTIVE (TTI) 🟢 KEY CONTENT IS AVAILABLE ALMOST IMMEDIATELY TO THE USER 🟢 STATIC CONTENT IS RENDERED ON THE SERVER = PAGES ARE SEO-FRIENDLY GREAT 🟡 HIGHLY INTERACTIVE PAGES WOULD PROBABLY REQUIRE THOUSANDS OF ISLANDS NOT GREAT ISLANDS ARCHITECTURE
  32. #hotTake 🌶 A considerable part of the modern isomorphic landscape

    is built on the back of libraries that weren't initially created for server rendering.
  33. HYDRATION: THE BAD PARTS™ INITIAL REQUEST HTML ARRIVES VIEW PAINTED

    JAVASCRIPT ARRIVES JAVASCRIPT IS PARSED — RESUMABILITY, WTF?, BY RYAN CARNIATO 0 100
  34. HYDRATION: THE BAD PARTS™ GET HTML DOWNLOAD JS PARSE +

    EXECUTE JS RECOVER STATE + BIND LISTENERS
  35. HYDRATION: THE BAD PARTS™ GET HTML DOWNLOAD JS PARSE +

    EXECUTE JS RECOVER STATE + BIND LISTENERS 🟢 FAST (USUALLY)
  36. HYDRATION: THE BAD PARTS™ GET HTML DOWNLOAD JS PARSE +

    EXECUTE JS RECOVER STATE + BIND LISTENERS 🔴 SLOW (ON BAD NETWORK CONDITIONS)
  37. HYDRATION: THE BAD PARTS™ GET HTML DOWNLOAD JS PARSE +

    EXECUTE JS RECOVER STATE + BIND LISTENERS 🔴 SLOW (DEPENDING ON THE DEVICE AND AMOUNT OF JAVASCRIPT)
  38. HYDRATION: THE BAD PARTS™ GET HTML DOWNLOAD JS PARSE +

    EXECUTE JS RECOVER STATE + BIND LISTENERS 🔴 SLOW (DEPENDING ON THE AMOUNT OF DOM NODES TO BE TRAVERSED AND REFERENCES TO BE RE-BOUND TO LISTENERS)
  39. HYDRATION → RESUMABILITY GET HTML DOWNLOAD JS PARSE + EXECUTE

    JS RECOVER STATE + BIND LISTENERS GET HTML 🔴 READY 🟢 READY
  40. #definition 📖 Resumability is about pausing execution in the server

    and resuming execution in the client without having to replay and download all of the application logic. — RESUMABLE VS. HYDRATION, QWIK
  41. ↝ SOME WORK → PAUSE → RESUME ↝ USE WHAT

    HAPPENED DURING THE EXECUTION ON THE SERVER AND AVOID EXTRA WORK WHEN THE APPLICATION STARTS IN THE BROWSER ↝ ATTACHES GLOBAL EVENT HANDLERS AT STARTUP AND THEN ONLY RUNS THE NECESSARY CODE ON INTERACTION RESUMABILITY
  42. ↝ EVENT HANDLER CREATION HAPPENS BEFORE THE EVENT IS TRIGGERED

    (EAGER) ↝ ALL POSSIBLE EVENT HANDLERS ARE CREATED AND REGISTERED (SPECULATIVE) ↝ CLIENT REDOES WORK ↝ REQUIRES THE FRAMEWORK TO DOWNLOAD AND EXECUTE THE COMPONENTS TO FIGURE OUT HIERARCHY HYDRATION ↝ EVENT HANDLER CREATION HAPPENS AFTER THE EVENT IS TRIGGERED (LAZY) ↝ ONLY TRIGGERED EVENTS ARE CREATED AND REGISTERED (AS-NEEDED) ↝ CLIENT DOESN'T REDO WORK (VIA DESERIALIZATION) ↝ REQUIRES ALL THE INFORMATION TO BE SERIALIZED IN THE HTML RESUMABILITY HYDRATION VS. RESUMABILITY
  43. ↝ EVENT HANDLER CREATION HAPPENS BEFORE THE EVENT IS TRIGGERED

    (EAGER) ↝ ALL POSSIBLE EVENT HANDLERS ARE CREATED AND REGISTERED (SPECULATIVE) ↝ CLIENT REDOES WORK ↝ REQUIRES THE FRAMEWORK TO DOWNLOAD AND EXECUTE THE COMPONENTS TO FIGURE OUT HIERARCHY HYDRATION ↝ EVENT HANDLER CREATION HAPPENS AFTER THE EVENT IS TRIGGERED (LAZY) ↝ ONLY TRIGGERED EVENTS ARE CREATED AND REGISTERED (AS-NEEDED) ↝ CLIENT DOESN'T REDO WORK (VIA DESERIALIZATION) ↝ REQUIRES ALL THE INFORMATION TO BE SERIALIZED IN THE HTML RESUMABILITY HYDRATION VS. RESUMABILITY
  44. ↝ EVENT HANDLER CREATION HAPPENS BEFORE THE EVENT IS TRIGGERED

    (EAGER) ↝ ALL POSSIBLE EVENT HANDLERS ARE CREATED AND REGISTERED (SPECULATIVE) ↝ CLIENT REDOES WORK ↝ REQUIRES THE FRAMEWORK TO DOWNLOAD AND EXECUTE THE COMPONENTS TO FIGURE OUT HIERARCHY HYDRATION ↝ EVENT HANDLER CREATION HAPPENS AFTER THE EVENT IS TRIGGERED (LAZY) ↝ ONLY TRIGGERED EVENTS ARE CREATED AND REGISTERED (AS-NEEDED) ↝ CLIENT DOESN'T REDO WORK (VIA DESERIALIZATION) ↝ REQUIRES ALL THE INFORMATION TO BE SERIALIZED IN THE HTML RESUMABILITY HYDRATION VS. RESUMABILITY
  45. RESUMABILITY: SERIALIZATION { "handlers": [ … ], "state": { …

    }, "hierarchy": { … }, } DISPLAY HTML RESUME STATE (JSON PARSE) 🟢 INTERACTIVE
  46. RESUMABILITY: SERIALIZATION { "handlers": [ … ], "state": { …

    }, "hierarchy": { … }, } DISPLAY HTML RESUME STATE (JSON PARSE) 🟢 INTERACTIVE
  47. RESUMABILITY: SERIALIZATION { "handlers": [ … ], "state": { …

    }, "hierarchy": { … }, } DISPLAY HTML RESUME STATE (JSON PARSE) 🟢 INTERACTIVE
  48. ↝ EVENT HANDLER CREATION HAPPENS BEFORE THE EVENT IS TRIGGERED

    (EAGER) ↝ ALL POSSIBLE EVENT HANDLERS ARE CREATED AND REGISTERED (SPECULATIVE) ↝ CLIENT REDOES WORK ↝ REQUIRES THE FRAMEWORK TO DOWNLOAD AND EXECUTE THE COMPONENTS TO FIGURE OUT HIERARCHY HYDRATION ↝ EVENT HANDLER CREATION HAPPENS AFTER THE EVENT IS TRIGGERED (LAZY) ↝ ONLY TRIGGERED EVENTS ARE CREATED AND REGISTERED (AS-NEEDED) ↝ CLIENT DOESN'T REDO WORK (VIA DESERIALIZATION) ↝ REQUIRES ALL THE INFORMATION TO BE SERIALIZED IN THE HTML RESUMABILITY HYDRATION VS. RESUMABILITY
  49. ↝ CLIENT REDOES WORK ↝ ISLAND-LEVEL ISLANDS ↝ CLIENT DOESN'T

    REDO WORK ↝ SUB-COMPONENT LEVEL (SMALLER) RESUMABILITY HYDRATION VS. RESUMABILITY 🍺
  50. #hotTake 🌶 Qwik is an example of the outside of

    the box thinking that is sometimes required on the web.
  51. 🟢 STARTUP PERFORMANCE 🟢 RENDERING PERFORMANCE (ONLY CHANGED COMPONENTS NEED

    TO BE RE-RENDERED) 🟢 FINE-GRAINED LAZY-LOADING 🟢 PROGRESSIVE INTERACTIVITY GREAT 🟡 *PRELOAD CRITICAL PAGE INTERACTIONS 🟡 THE ONLY OPTION FOR DEVELOPERS TO LEVERAGE RESUMABILITY IS TO USE QWIK 🟡 TOO LITTLE DISCUSSION AVAILABLE ON THE IDEA NOT GREAT RESUMABILITY
  52. 🟢 STARTUP PERFORMANCE 🟢 RENDERING PERFORMANCE (ONLY CHANGED COMPONENTS NEED

    TO BE RE-RENDERED) 🟢 FINE-GRAINED LAZY-LOADING 🟢 PROGRESSIVE INTERACTIVITY GREAT 🟡 *PRELOAD CRITICAL PAGE INTERACTIONS 🟡 THE ONLY OPTION FOR DEVELOPERS TO LEVERAGE RESUMABILITY IS TO USE QWIK 🟡 TOO LITTLE DISCUSSION AVAILABLE ON THE IDEA NOT GREAT RESUMABILITY
  53. ↝ NODE STREAMS ALLOW US TO CONTINUOUSLY SEND DATA DOWN

    TO THE CLIENT ↝ LOAD DATA OVER A NETWORK IN MULTIPLE CHUNKS ↝ THE CHUNKS ARE LOADED OUT OF ORDER IN PARALLEL TO RENDERING STREAMING SSR
  54. #case💡 An e-commerce. Product pages have a lot of personalized

    content: localized description, a dynamic list of recommended products powered and a custom deals banner.
  55. 🟢 FAST TIME TO FIRST BYTE (TTFB) 🟢 FASTER FIRST

    CONTENTFUL PAINT (FCP) AND TIME TO INTERACTIVE (TTI) 🟢 HANDLING OF BACKPRESSURE 🟢 BRIDGES THE GAP BETWEEN A PURE SSR AND A CSR EXPERIENCE GREAT 🟡 MIGRATION WASN’T ALWAYS EASY NOT GREAT STREAMING SSR
  56. 🟢 FAST TIME TO FIRST BYTE (TTFB) 🟢 FASTER FIRST

    CONTENTFUL PAINT (FCP) AND TIME TO INTERACTIVE (TTI) 🟢 HANDLING OF BACKPRESSURE 🟢 BRIDGES THE GAP BETWEEN A PURE SSR AND A CSR EXPERIENCE GREAT 🟡 MIGRATION WASN’T ALWAYS EASY NOT GREAT STREAMING SSR
  57. HYDRATION IN REACT (THE BAD PARTS™) FETCHING DATA (SERVER) RENDERING

    HTML (SERVER) LOADING CODE (CLIENT) HYDRATING TIME TO FIRST BYTE FIRST CONTENTFUL PAINT TIME TO INTERACTIVE
  58. HYDRATION IN REACT (THE BAD PARTS™) ↝ HYDRATION COULD ONLY

    BEGIN AFTER THE ENTIRE DATA WAS FETCHED AND RENDERED ↝ USERS COULDN’T INTERACT WITH THE PAGE UNTIL HYDRATION WAS COMPLETE FOR THE WHOLE PAGE ↝ PARTS OF YOUR APP THAT LOAD FAST WOULD ALWAYS HAVE TO WAIT FOR THE SLOW ONES
  59. (STREAMING SSR +) SELECTIVE HYDRATION FETCHING DATA (SERVER) RENDERING HTML

    (SERVER) LOADING CODE (CLIENT) HYDRATING TIME TO FIRST BYTE FIRST CONTENTFUL PAINT TIME TO INTERACTIVE
  60. TIME TO FIRST BYTE FIRST CONTENTFUL PAINT TIME TO INTERACTIVE

    […] FETCHING DATA (SERVER) RENDERING HTML (SERVER) HYDRATING LOADING CODE (CLIENT) […] […] […] […] […] […] (STREAMING SSR +) SELECTIVE HYDRATION
  61. ↝ pipeToNodeStream + createRoot + <Suspense> ↝ REACT PRIORITIZES HYDRATING

    THE PARTS THAT THE USER INTERACTED WITH BEFORE THE REST ↝ COMPONENTS CAN BECOME INTERACTIVE FASTER BY ALLOWING THE BROWSER TO DO OTHER WORK AT THE SAME TIME AS HYDRATION (STREAMING SSR +) SELECTIVE HYDRATION
  62. ↝ REACT WON'T WAIT FOR HUGE COMPONENTS TO LOAD TO

    CONTINUE STREAMING HTML FOR THE REST OF THE PAGE ↝ WHEN THE HTML BECOMES AVAILABLE ON THE SERVER, IT WILL BE ADDED TO THE SAME STREAM ALONG WITH A SCRIPT TAG AND INSERTED IN THE RIGHT PLACE (STREAMING SSR +) SELECTIVE HYDRATION
  63. 🟢 LOWER FIRST INPUT DELAY (FID) 🟢 LOWER INTERACTION TO

    NEXT PAINT (INP) GREAT NOT GREAT (STREAMING SSR +) SELECTIVE HYDRATION
  64. ↝ EVENT HANDLER CREATION HAPPENS BEFORE THE EVENT IS TRIGGERED

    (EAGER) ↝ ALL POSSIBLE EVENT HANDLERS ARE CREATED AND REGISTERED (SPECULATIVE) ↝ CLIENT REDOES WORK ↝ REQUIRES THE FRAMEWORK TO DOWNLOAD AND EXECUTE THE COMPONENTS TO FIGURE OUT HIERARCHY HYDRATION ↝ EVENT HANDLER CREATION HAPPENS AFTER THE EVENT IS TRIGGERED (LAZY) ↝ ONLY TRIGGERED EVENTS ARE CREATED AND REGISTERED (AS-NEEDED) ↝ CLIENT DOESN'T REDO WORK (VIA DESERIALIZATION) ↝ REQUIRES ALL THE INFORMATION TO BE SERIALIZED IN THE HTML RESUMABILITY HYDRATION VS. RESUMABILITY
  65. ↝ EVENT HANDLER CREATION HAPPENS BEFORE THE EVENT IS TRIGGERED

    (EAGER) ↝ ALL POSSIBLE EVENT HANDLERS ARE CREATED AND REGISTERED (SPECULATIVE) ↝ CLIENT REDOES WORK ↝ REQUIRES THE FRAMEWORK TO DOWNLOAD AND EXECUTE THE COMPONENTS TO FIGURE OUT HIERARCHY SELECTIVE HYDRATION ↝ EVENT HANDLER CREATION HAPPENS AFTER THE EVENT IS TRIGGERED (LAZY) ↝ ONLY TRIGGERED EVENTS ARE CREATED AND REGISTERED (AS-NEEDED) ↝ CLIENT DOESN'T REDO WORK (VIA DESERIALIZATION) ↝ REQUIRES ALL THE INFORMATION TO BE SERIALIZED IN THE HTML RESUMABILITY HYDRATION VS. RESUMABILITY
  66. ↝ AHEAD-OF-TIME REACT RENDERING (DURING THE BUILD OR ON THE

    SERVER) ↝ A ROUTING PARADIGM ↝ INTEGRATED WITH DATA FETCHING AND BUNDLING ↝ UNRELATED TO SSR (AND HYDRATION) REACT SERVER COMPONENTS
  67. ↝ ALMOST IDENTICAL TO HOW ISLANDS WORK ↝ “use client”

    MARKS A BOUNDARY BETWEEN TWO MODULE GRAPHS ↝ EACH COMPONENT DECIDES WHETHER TO BE A SERVER COMPONENT OR TO STICK WITH BEING A SERVER + CLIENT COMPONENT REACT SERVER COMPONENTS
  68. ↝ CODE FOR SERVER COMPONENTS IS NEVER DELIVERED TO THE

    CLIENT ↝ ACCESS TO THE BACK-END FROM THE TREE ↝ MAY BE REFETCHED WHILE MAINTAINING CLIENT- SIDE STATE INSIDE OF THE TREE REACT SERVER COMPONENTS
  69. 🟢 PURELY ADDITIVE 🟢 SMALLER BUNDLES 🟢 FASTER REHYDRATION (FEWER

    COMPONENTS ON THE CLIENT) GREAT 🟡 A LOT OF DATA TO SEND ALONG THE WIRE EVERY SERVER RE-RENDER 🟡 MUCH MORE ORCHESTRATION NEEDED 🟡 STILL EXPERIMENTAL 🟡 ONLY FEW OPTIONS FOR DEVELOPERS TO LEVERAGE RSC NOT GREAT REACT SERVER COMPONENTS
  70. 🟢 PURELY ADDITIVE 🟢 SMALLER BUNDLES 🟢 FASTER REHYDRATION (FEWER

    COMPONENTS ON THE CLIENT) GREAT 🟡 A LOT OF DATA TO SEND ALONG THE WIRE EVERY SERVER RE-RENDER 🟡 MUCH MORE ORCHESTRATION NEEDED 🟡 STILL EXPERIMENTAL 🟡 ONLY FEW OPTIONS FOR DEVELOPERS TO LEVERAGE RSC NOT GREAT REACT SERVER COMPONENTS
  71. < ! - - Database, file, and socket access from

    JavaScript - - > <script runat="server"> var resultSet = Jaxer.DB.execute("SELECT * FROM myTable"); var newPrice = resultSet.rows[0].price; </script> < ! - - Directly call server-side functions from the browser - - > <script runat="server-proxy"> function getPriceFromServer() { return 42; } </script> <button onclick="alert(getPriceFromServer())">Price</button> < ! - - Share validation code on the browser and server - - > <script runat="both"> function validateCreditCard(number) {} </script> REACT SERVER COMPONENTS (PRIOR ART)
  72. < ! - - Database, file, and socket access from

    JavaScript - - > <script runat="server"> var resultSet = Jaxer.DB.execute("SELECT * FROM myTable"); var newPrice = resultSet.rows[0].price; </script> < ! - - Directly call server-side functions from the browser - - > <script runat="server-proxy"> function getPriceFromServer() { return 42; } </script> <button onclick="alert(getPriceFromServer())">Price</button> < ! - - Share validation code on the browser and server - - > <script runat="both"> function validateCreditCard(number) {} </script> REACT SERVER COMPONENTS (PRIOR ART)
  73. #definition 🧐 Edge Functions allow you to serve content from

    the CDN server closest to the user. — UNDERSTANDING EDGE FUNCTIONS: THE EDGE AND BEYOND
  74. THE EDGE ↝ BRINGING COMPUTING CLOSER TO THE SOURCE OF

    THE DATA ↝ FEWER PROCESSES IN THE CLOUD ↝ MINIMIZES THE NEED FOR LONG DISTANCE COMMUNICATIONS BETWEEN CLIENT AND SERVER ↝ REDUCES LATENCY AND BANDWIDTH USAGE
  75. ↝ 🦾 IOT DEVICES ↝ 🔒 SECURITY SYSTEM MONITORING ↝

    🏥 MEDICAL MONITORING DEVICES ↝ 🚗 SELF-DRIVING CARS THE EDGE
  76. 1998 2001 2006 2012 2014 2016 AKAMAI CDN PEER-TO-PEER CLOUD

    COMPUTING FOG COMPUTING AWS LAMBDA JAMSTACK THE EDGE: TIMELINE
  77. 1998 2006 2012 2014 2016 THE EDGE: TIMELINE 2001 2017

    CLOUDFLARE WORKERS DENO VERCEL EDGE RUNTIME NETLIFY EDGE FUNCTIONS 
 2022
  78. THE EDGE Location Heroku TTFB Frankfurt 339.95ms Amsterdam 382.62ms London

    338.09ms New York 47.55ms Dallas 144.64ms San Francisco 302ms Singapore 944.14ms Sydney 889.85ms Tokyo 672.49ms Bangalore 984.39ms — THE FUTURE OF THE WEB IS ON THE EDGE, BY ANDY JIANG
  79. THE EDGE Location Heroku TTFB Deno TTFB Frankfurt 339.95ms 28.45ms

    Amsterdam 382.62ms 29.72ms London 338.09ms 22.3ms New York 47.55ms 41.29ms Dallas 144.64ms 29.28ms San Francisco 302ms 44.24ms Singapore 944.14ms 528.57ms Sydney 889.85ms 26.46ms Tokyo 672.49ms 19.04ms Bangalore 984.39ms 98.23ms — THE FUTURE OF THE WEB IS ON THE EDGE, BY ANDY JIANG
  80. IT ALL SOUNDS INCREDIBLY COMPLEX! WE'RE ADDRESSING THE UNCERTAINTIES OF

    THE MODERN WEB WHEN IT COMES TO CONNECTION QUALITY AND CLIENT DEVICE COMPUTATIONAL CAPABILITY. #1 HYDRATION, ISLANDS, STREAMING, RESUMABILITY… OH MY!
  81. THE SAME PATTERN CAN BE BENEFICIAL AND DETRIMENTAL IT IS

    ALSO QUITE LIKELY THAT DIFFERENT TYPES OF PAGES REQUIRE DIFFERENT RENDERING PATTERNS ON THE SAME WEBSITE. #2 HYDRATION, ISLANDS, STREAMING, RESUMABILITY… OH MY!
  82. APPLICATION HOLOTYPES Portfolio Content Storefront Social Network I m m

    ersive Holotype Personal Blog CNN Amazon Facebook Figma Interactivity Minimal Linked Articles Purchase Multi-Point, Real-time Everything Session Depth Shallow Shallow Shallow - Medium Extended Deep Values Simplicity Discover-ability Load Performance Dynamicism I m m ersiveness Routing Server Server, HTML Swap HTML Swap, Hybrid Hybrid, Client Client Rendering Static Static, SSR Static, SSR SSR CSR Hydration None Progressive, Partial Partial, Resumable Any None (CSR) Frameworks 11ty Astro, Elder Marko, Qwik, Hydrogen Next, Remix Create React App — PATTERNS FOR BUILDING JAVASCRIPT WEBSITES IN 2022, BY RYAN CARNIATO
  83. THE SOLUTION TO THE PROBLEM ONLY CHANGES THE PROBLEM. #3

    HYDRATION, ISLANDS, STREAMING, RESUMABILITY… OH MY!
  84. IT'S EASY TO THINK WE'RE JUST GOING BACK TO RENDERING

    HTML ON THE SERVER BUT THESE DAYS THE BOUNDARIES ARE VERY DIFFERENT. #4 HYDRATION, ISLANDS, STREAMING, RESUMABILITY… OH MY!
  85. SOFTWARE DEVELOPMENT CONTINUALLY GOES THROUGH CYCLES. WHAT'S DIFFERENT NOW? #5

    HYDRATION, ISLANDS, STREAMING, RESUMABILITY… OH MY!
  86. THERE'S NO SILVER BULLET. IDENTIFY YOUR CORE METRICS. ALWAYS TRY

    TO CORRELATE BUSINESS METRICS WITH PERFORMANCE. #6 HYDRATION, ISLANDS, STREAMING, RESUMABILITY… OH MY!
  87. THIS IS ME, NINE YEARS AGO, GIVING A TALK ABOUT

    IONIC AT AN IOS DEVELOPERS MEETUP TELLING THEM THAT ANGULAR WOULD BE THE FUTURE.
  88. THAT’S ALL, FOLKS! THANKS! 👋 🇮🇨 QUESTIONS? ↑ ALL THE

    LINKS! 🤓 HYDRATION, ISLANDS, STREAMING, RESUMABILITY… OH MY! MATHEUS ALBUQUERQUE • @ythecombinator