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

The Frontend Dichotomy

The Frontend Dichotomy

The Frontend Dichotomy: prerender and prefetch everything that user will use, and also defer render and fetches that user won’t use right now

Sibelius Seraphini

October 20, 2018
Tweet

More Decks by Sibelius Seraphini

Other Decks in Programming

Transcript

  1. Frontend Dichotomy 3 - prerender and prefetch everything that user

    will use - defer render and fetches what user won’t use right now
  2. React Time Slicing 4 - React doesn't block the thread

    while rendering - Feel synchronous if device is fast - Feel responsive if device is slow - Only the final rendered state is displayed - Same declarative component model
  3. React Suspense 5 - Pause any state update until the

    data is ready - Add async data to any component without "plumbing" - On a fast network, render after the whole tree is ready - On a slow network, precisely control the loading states
  4. React - Async Rendering 6 - Time slicing + Suspense

    - Adapt to user's device and network - Fast interactions feels instant - Slower interactions feels responsive
  5. Prerender 7 - prerender on server (SSR) - prerender time

    slicing - cache render (SSR Rapscallion)
  6. Prefetch 9 - prefetch on server (SSR) - prefetch before

    mounting a component - cache resources - service worker - suspense / react-cache - prefetch next page on click hover
  7. Defer Render 14 - defer render on server (SSR) -

    defer code loading (code split) - defer media queries to client side (suspend) - defer work to improve animations
  8. Code splitting 16 - React.lazy (Suspense) - code split per

    route - code split modals - code split large modules - preload based on heuristics (visibility?)
  9. Defer Media Queries 17 - Server renders loading where media

    queries(width/height) is needed - Client render using media queries - React Suspense makes this work well.
  10. Defer Fetch 19 - only ask for data needed now

    - lazy loading following data
  11. Fetch Strategies 20 - cache only - network only -

    cache falling back to network - network falling back to cache - cache then network
  12. Deferrable Queries - Relay Modern 23 - @relay(defer: true) modifies

    generated queries - Multiples requests/fetches to GraphQL server - Resolves data using Observable
  13. @defer - Apollo 25 - @defer - Single request to

    GraphQL server - Stream patches using multipart over HTTP - Uses a modified version of GraphQL Execution on server to resolve the patches
  14. Defer on GraphQL - WIP 26 - Still too bleeding

    edge - Deferrable Queries was removed this week from Relay master - @defer is still on a pull request
  15. Resources 29 - https://medium.com/entria/relay-modern-network-deep-dive-ec 187629dfd3 - https://github.com/jamiebuilds/react-loadable - https://github.com/stratiformltd/react-loadable-visibility -

    https://github.com/facebook/react/pull/13398 - https://github.com/facebook/relay/issues/2194 - https://blog.apollographql.com/introducing-defer-in-apollo-serv er-f6797c4e9d6e - https://github.com/kriskowal/gtor
  16. Resources 30 - https://github.com/relay-tools/fetch-multipart-graphql - https://developers.google.com/web/updates/2015/08/using-req uestidlecallback - https://facebook.github.io/react-native/docs/interactionmanager -

    https://medium.com/@jonatan_salas/a-walk-through-react-exp erimental-features-562baeb8a63a - https://github.com/acdlite/react-fiber-architecture - https://www.facebook.com/pg/react/videos/