Slide 1

Slide 1 text

1 Oct o b e r 21, 20 19 | Muni ch F ul l S t a ck D a y Architectures for Modern Web Front Ends LUCAS DOHMEN @moonbeamlabs

Slide 2

Slide 2 text

2

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

Hydration 13 Static HT FCP TTI load & run App How to simulate readiness? What about Events (Clicks etc)? How to match server-side HTML to client-side DOM?

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

20

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

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

Slide 23

Slide 23 text

23 My fancy blog Lorem Ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem Ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Comment Use SSR for the page Use React/Vue/… for the WYSIWYG editor …as a progressive enhancement …or custom elements Work with and think in components

Slide 24

Slide 24 text

24 My suggestion for 99% of Web apps: Use Server-Side Rendering and Progressive Enhancement

Slide 25

Slide 25 text

Thanks! Questions? 25 Lucas Dohmen lucas.dohmen@innoq.com +49 151 75062496 @moonbeamlabs 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