Architectures for Modern Web Front Ends
2 0 2 0 / 0 5 / 2 6 J U G S w i t z e r l a n d
Stefan Tilkov @stilkov Lucas Dohmen @moonbeamlabs
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.
2 0 2 0 / 0 5 / 2 6 J U G S w i t z e r l a n d
Stefan Tilkov @stilkov Lucas Dohmen @moonbeamlabs
1) in the SOAP/WSDL sense
2) built as a careless SPA
> Uses HTTP as transport > Ignores HTTP verbs > Ignores URIs > Exposes single “endpoint” > Fails to embrace the Web > Uses browser as runtime > Ignores forward, back, refresh > Does not support linking > Exposes monolithic “app” > Fails to embrace the browser
Process Flow Presentation Domain Logic Data
Server Client > Rendering, layout, styling
> Logic & state machine on server > Client user-agent extensible via code on demand
implementation
A great REST hypermedia API is very similar to a simple, server-sided rendered web application
State Business Logic Routing Rendering Logic Look & Presentation Logic Server Client HTML
State Business Logic Routing Rendering Logic Look & Presentation Logic Server Client JSON
State Business Logic Routing Rendering Logic Look & Presentation Logic Server Client JSON JSON API JSON Client
Solution: Store some app state in the URI! Bookmarks? Deep links? Reload?
Browser Server GET / 200 OK… GET /app.js 200 OK… App start…
State Business Logic Routing Rendering Logic Look & Presentation Logic Server Client JSON JSON API JSON Client
State Business Logic Routing Rendering Logic Look & Presentation Logic Server Client JSON JSON API JSON Client
Crawler Server GET / Static HTML Snapshot API run App AJAX Fun…
State Business Logic Routing Rendering Logic Look & Presentation Logic Server Client JSON JSON API JSON Client Rendering Logic Routing HTML
State Business Logic Routing Rendering Logic Look & Presentation Logic Server Client JSON JSON API JSON Client Rendering Logic Routing HTML
Same Code
Jake Archibald, developer advocate for Google Chrome
Browser Server GET / Static HTML Snapshot API run App AJAX Fun… FCP TTI
load & run App
AJAX Fun…
How to simulate readiness? What about Events (Clicks etc)? How to match server-side HTML to client-side DOM?
Browser GET / Static HTML Snapshot FCP TTI
load & run App
State Business Logic Routing Rendering Logic Look & Presentation Logic Server Client JSON JSON API JSON Client (Pre-)Rendering Logic Routing HTML
State Business Logic Routing Rendering Logic Look & Presentation Logic Server Client JSON JSON API JSON Client (Pre-)Rendering Logic Routing HTML Hydration
JSON API Routing Rendering Logic Look & Presentation Logic Server Client JSON JSON Client (Pre-)Rendering Logic Routing HTML Hydration Business Logic State Business Logic
Same functionality, different languages!
State
State Business Logic JSON API Business Logic State Routing Rendering Logic Look & Presentation Logic Server Client JSON JSON Client (Pre-)Rendering Logic Routing HTML Hydration
high control, high observability low control, low observability
State Routing Rendering Logic Look & Presentation Logic Server Client JSON JSON Client (Pre-)Rendering Logic Routing HTML Hydration Business Logic JSON API State Business Logic
Much, much more client side JavaScript
37
customElement.define( "my-element", MyElement );
Modern API in JS Modern API in CSS
.item { display: contents; }
Firefox 63: It works Firefox 63: It works Chrome 69: Exception Chrome 69: Skips that line
Addy Osmani, Speed team lead for Google Chrome
Pixel 3 Moto G4 Alcatel 2X 5059D 0 seconds 1 second 2 seconds
Main thread Worker thread
The cost of JavaScript in 2019
(No, an emulator is not enough)
“15% of users tried to interact sometime between
Akamai: Metrics That Matter
State Business Logic Routing Rendering Logic Look & Presentation Logic Server Client HTML
State Business Logic Routing Rendering Logic Look & Presentation Logic Server Client HTML Rendering Logic Look & Presentation Logic JSON/ HTML
48
and future devices
state
landscape
state
40789 Monheim am Rhein Germany +49 2173 3366-0 Ohlauer Str. 43 10999 Berlin Germany +49 2173 3366-0
63067 Offenbach Germany +49 2173 3366-0
80331 München Germany +49 2173 3366-0 Hermannstrasse 13 20095 Hamburg Germany +49 2173 3366-0
CH-6330 Cham Switzerland +41 41 743 0116
innoQ Deutschland GmbH innoQ Schweiz GmbH
www.innoq.com
50
Stefan Tilkov stefan.tilkov@innoq.com +49 170 4712625 stilkov Lucas Dohmen lucas.dohmen@innoq.com +49 151 75062496 moonbeamlabs