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

architectures for modern web front ends
SMART_READER_LITE
LIVE PREVIEW

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.


slide-1
SLIDE 1

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

slide-2
SLIDE 2

Annoying your app users in 10 easy steps

slide-3
SLIDE 3

1. Forbid the use of the back and forward buttons

slide-4
SLIDE 4

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

slide-5
SLIDE 5

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

slide-6
SLIDE 6

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

slide-7
SLIDE 7

5. Let them see UI decoration and ads first, content last

slide-8
SLIDE 8

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

slide-9
SLIDE 9

7. Don’t let Google index anything

slide-10
SLIDE 10

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

slide-11
SLIDE 11

9. Disable assistive

  • technologies. Who needs a

screen reader, anyway?

slide-12
SLIDE 12

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

slide-13
SLIDE 13

History repeating …

CORBA Web WS-* REST

slide-14
SLIDE 14

What’s the client side analogy?

slide-15
SLIDE 15

1) in the SOAP/WSDL sense

“Web app”2)

2) built as a careless SPA

“Web service”1)

> 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

slide-16
SLIDE 16

The web-native way of distributing logic

Process Flow Presentation Domain Logic Data

Server Client > Rendering, layout, styling

  • n an unknown client

> Logic & state machine on server > Client user-agent extensible via code on demand

slide-17
SLIDE 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
slide-18
SLIDE 18

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

slide-19
SLIDE 19

The role of JS in modern Web applications

slide-20
SLIDE 20

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

slide-21
SLIDE 21

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

slide-22
SLIDE 22

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

slide-23
SLIDE 23

Why Routing?

Solution: Store some app state in the URI! Bookmarks? Deep links? Reload?

Browser Server GET / 200 OK… GET /app.js 200 OK… App start…

slide-24
SLIDE 24

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

slide-25
SLIDE 25

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

slide-26
SLIDE 26

Searchability

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

slide-27
SLIDE 27

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

slide-28
SLIDE 28

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

Same Code

slide-29
SLIDE 29

“All your users are non-JS users while they‘re downloading your JS”

Jake Archibald, developer advocate for Google Chrome

slide-30
SLIDE 30

Prerendering

Browser Server GET / Static HTML Snapshot API run App AJAX Fun… FCP TTI

load & run App

AJAX Fun…

slide-31
SLIDE 31

Hydration

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

slide-32
SLIDE 32

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

slide-33
SLIDE 33

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

slide-34
SLIDE 34

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

slide-35
SLIDE 35

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

slide-36
SLIDE 36

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

slide-37
SLIDE 37

37

Resilience

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

slide-38
SLIDE 38

“JavaScript is the most expensive part of your page”

Addy Osmani, Speed team lead for Google Chrome

slide-39
SLIDE 39

Cost of JavaScript on Reddit.com

Pixel 3 Moto G4 Alcatel 2X 5059D 0 seconds 1 second 2 seconds

Main thread Worker thread

The cost of JavaScript in 2019

slide-40
SLIDE 40

Test your app on real, low-cost devices and slow networks

(No, an emulator is not enough)

slide-41
SLIDE 41
slide-42
SLIDE 42

RAGE CLICKS

“15% of users tried to interact sometime between

  • nload and interactive.”

Akamai: Metrics That Matter

RAGE CLICKS

slide-43
SLIDE 43

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

slide-44
SLIDE 44

Now what?

slide-45
SLIDE 45
  • Client-side state handling
  • Better offline support
  • Closer to desktop model
  • Better performance
  • Server-side state handling
  • Simpler
  • More resilient & observable
  • Smaller client footprint
  • Better performance
slide-46
SLIDE 46

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

slide-47
SLIDE 47

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

slide-48
SLIDE 48

48

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

slide-49
SLIDE 49

Pure SPA SSR+RC Pure SSR

  • Large number of users
  • Basic UX needs
  • Support for past, present

and future devices

  • Complex global client

state

  • Offline support
  • Controlled device

landscape

  • Like SSR, but with
  • more UX needs
  • Complex component

state

  • Basic offline support
slide-50
SLIDE 50
  • Krischerstr. 100

40789 Monheim am Rhein Germany +49 2173 3366-0 Ohlauer Str. 43 10999 Berlin Germany +49 2173 3366-0

  • Ludwigstr. 180E

63067 Offenbach Germany +49 2173 3366-0

  • Kreuzstr. 16

80331 München Germany +49 2173 3366-0 Hermannstrasse 13 20095 Hamburg Germany +49 2173 3366-0

  • Gewerbestr. 11

CH-6330 Cham Switzerland +41 41 743 0116

innoQ Deutschland GmbH innoQ Schweiz GmbH

www.innoq.com

50

Thanks! Questions?

Stefan Tilkov stefan.tilkov@innoq.com +49 170 4712625 stilkov Lucas Dohmen lucas.dohmen@innoq.com +49 151 75062496 moonbeamlabs