architectures for modern web front ends
play

Architectures for Modern Web Front Ends Stefan Tilkov Lucas - PowerPoint PPT Presentation

2 0 2 0 / 0 5 / 2 6 J U G S w i t z e r l a n d Architectures for Modern Web Front Ends Stefan Tilkov Lucas Dohmen @stilkov @moonbeamlabs Annoying your app users in 10 easy steps 1. Forbid the use of the back and forward buttons 2.


  1. 2 0 2 0 / 0 5 / 2 6 J U G S w i t z e r l a n d Architectures for Modern Web Front Ends Stefan Tilkov Lucas Dohmen @stilkov @moonbeamlabs

  2. Annoying your app users in 10 easy steps

  3. 1. Forbid the use of the back and forward buttons

  4. 2. Send them to the home page when they hit “refresh” …

  5. 3. … or at least ensure the browser pops up a warning window

  6. 4. Make sure they can’t open a second browser window

  7. 5. Let them see UI decoration and ads f irst, content last

  8. 6. Make sure they can’t bookmark or send a link

  9. 7. Don’t let Google index anything

  10. 8. Show users a picture of your app – it’s surely better than nothing

  11. 9. Disable assistive technologies. Who needs a screen reader, anyway?

  12. 10. Ensure non-functioning JavaScript gives them a blank page

  13. History repeating … Web CORBA WS-* REST

  14. What’s the client side analogy?

  15. “Web service” 1) “Web app” 2) > Uses HTTP as transport > Uses browser as runtime > Ignores HTTP verbs > Ignores forward, back, refresh > Ignores URIs > Does not support linking > Exposes single “endpoint” > Exposes monolithic “app” > Fails to embrace the Web > Fails to embrace the browser 1) in the SOAP/WSDL sense 2) built as a careless SPA

  16. The web-native way of distributing logic > Rendering, layout, styling Client Presentation on an unknown client > Logic & state machine on Process Flow Server server > Client user-agent Domain Logic extensible via code on demand Data

  17. HTML & Hypermedia • In REST, servers expose a hypermedia format • Option 1: Just invent your own JSON-based, incomplete clone • Option 2: Just use HTML • Clients need to be RESTful, too • Option 1: Invent your own, JS-based, buggy, incomplete implementation • Option 2: Use the browser

  18. A great REST hypermedia API is very similar to a simple, server-sided rendered web application

  19. The role of JS in modern Web applications

  20. State Business Logic Routing Rendering Logic HTML Server Client Look & Presentation Logic

  21. State Business Logic Routing JSON Server Client Rendering Logic Look & Presentation Logic

  22. State Business Logic Routing JSON API JSON Server Client JSON Client Rendering Logic Look & Presentation Logic

  23. Why Routing? Bookmarks? Browser Server GET / Deep links? 200 OK… Reload? GET /app.js 200 OK… start… App Solution: Store some app state in the URI!

  24. State Business Logic Routing JSON API JSON Server Client JSON Client Rendering Logic Look & Presentation Logic

  25. State Business Logic JSON API JSON Server Client JSON Client Routing Rendering Logic Look & Presentation Logic

  26. Searchability Crawler Server API GET / AJAX Fun… run App Static HTML Snapshot

  27. State Business Logic Routing JSON API Rendering Logic JSON HTML Server Client JSON Client Routing Rendering Logic Look & Presentation Logic

  28. State Business Logic Routing JSON API Rendering Logic JSON HTML Same Code Server Client JSON Client Routing Rendering Logic Look & Presentation Logic

  29. “All your users are non-JS users while they‘re downloading your JS” Jake Archibald, developer advocate for Google Chrome

  30. Prerendering Browser Server API GET / AJAX Fun… run App Static HTML Snapshot FCP load & run AJAX Fun… App TTI

  31. Browser Hydration GET / How to simulate Static HTML Snapshot readiness? FCP What about Events load & run App (Clicks etc)? TTI How to match server-side HTML to client-side DOM?

  32. State Business Logic Routing JSON API (Pre-)Rendering Logic JSON HTML Server Client JSON Client Routing Rendering Logic Look & Presentation Logic

  33. State Business Logic Routing JSON API (Pre-)Rendering Logic JSON HTML Server Client JSON Client Hydration Routing Rendering Logic Look & Presentation Logic

  34. State Business Logic Routing JSON API (Pre-)Rendering Logic JSON HTML Server Same functionality, Client different languages! JSON Client Hydration Routing Rendering Logic Business Logic State Look & Presentation Logic

  35. State Business Logic Routing high control, JSON API (Pre-)Rendering Logic high observability JSON HTML Server Client JSON Client Hydration low control, Routing low observability Rendering Logic Business Logic State Look & Presentation Logic

  36. State Business Logic Routing JSON API (Pre-)Rendering Logic Much, much JSON HTML more client side JavaScript Server Client JSON Client Hydration Routing Rendering Logic Business Logic State Look & Presentation Logic

  37. Resilience Modern API in JS Modern API in CSS customElement.define( .item { "my-element", display: contents; MyElement } ); Firefox 63: It works Firefox 63: It works Chrome 69: Exception Chrome 69: Skips that line 37

  38. “JavaScript is the most expensive part of your page” Addy Osmani, Speed team lead for Google Chrome

  39. Cost of JavaScript on Reddit.com Pixel 3 Moto G4 Alcatel 2X 5059D 1 second 0 seconds 2 seconds Main thread Worker thread The cost of JavaScript in 2019

  40. Test your app on real, low-cost devices and slow networks (No, an emulator is not enough)

  41. RAGE CLICKS RAGE CLICKS “15% of users tried to interact sometime between onload and interactive.” Akamai: Metrics That Matter

  42. Hydration is not a progressive enhancement, it‘s an uncanny valley

  43. Now what?

  44. • Client-side state handling • Server-side state handling • Better of f line support • Simpler • Closer to desktop model • More resilient & observable • Better performance • Smaller client footprint • Better performance

  45. State Business Logic Routing Rendering Logic HTML Server Client Look & Presentation Logic

  46. State Business Logic Routing Rendering Logic JSON/ HTML HTML Server Client Rendering Logic Look & Presentation Logic Look & Presentation Logic

  47. Let's use the technologies from SPAs , but keep the architecture of the Web . 48

  48. • Complex global client • Like SSR, but with • Large number of users state • more UX needs • Basic UX needs • Of f line support • Complex component • Support for past, present • Controlled device state and future devices landscape • Basic of f line support Pure SSR SSR+RC Pure SPA

  49. Thanks! Questions? www.innoq.com Stefan Tilkov Lucas Dohmen stefan.tilkov@innoq.com lucas.dohmen@innoq.com +49 170 4712625 +49 151 75062496 stilkov moonbeamlabs innoQ Deutschland GmbH innoQ Schweiz GmbH Krischerstr. 100 Ohlauer Str. 43 Ludwigstr. 180E Kreuzstr. 16 Hermannstrasse 13 Gewerbestr. 11 40789 Monheim am Rhein 10999 Berlin 63067 Offenbach 80331 München 20095 Hamburg CH-6330 Cham Germany Germany Germany Germany Germany Switzerland +49 2173 3366-0 +49 2173 3366-0 +49 2173 3366-0 +49 2173 3366-0 +49 2173 3366-0 +41 41 743 0116 50

Recommend


More recommend