Slide 1

Slide 1 text

1 1 7 . S e p t e m b e r C o l o g n e . r b AdequateJS Lucas Dohmen

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

Single Page Apps – Why Routing? 8 Bookmarks? Deep links? Reload? Solution: Store some app state in the URI

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

Prerendering 11

Slide 10

Slide 10 text

Hydration 12 How to simulate readiness? What about Events (Clicks etc)? How to match server-side HTML to client-side DOM?

Slide 11

Slide 11 text

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

Slide 12

Slide 12 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 13

Slide 13 text

Special case: Searchability 15 No Hydration needed

Slide 14

Slide 14 text

16 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 Same functionality, different languages!

Slide 15

Slide 15 text

17 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 JavaScript

Slide 16

Slide 16 text

18 Everyone has JavaScript, right? All your users are non-JS while they're downloading your JS If they're on a train and their net connection goes away before your JavaScript loads, then there's no JavaScript. Did the HTTP request for the JavaScript complete? Does the corporate firewall block JavaScript? Does their ISP or mobile operator interfere with downloaded JavaScript? Does their browser support the JavaScript you’ve written? Do your users get the JavaScript?

Slide 17

Slide 17 text

19 The cost of JavaScript in 2019

Slide 18

Slide 18 text

Moving code to the client 20 On a server, we can write logs and catch and collect exceptions. This is also possible on the client, but is much more complex and error-prone.

Slide 19

Slide 19 text

Resilience of JavaScript 21 Modern API in JavaScript customElements.define( "my-element", MyElement ); Chrome 69 ! Firefox 63 ! Microsoft Edge 18 " Modern API in CSS .item { display: contents; } Chrome 69 # Firefox 63 ! Microsoft Edge 18 #

Slide 20

Slide 20 text

22 ROCA (Resource-oriented client architecture) ROCA-style.org

Slide 21

Slide 21 text

ROCA 23 RESTful Server-side HTML (SSR) Application logic only on server No duplicated logic on client + No application logic on client! Client-side (self contained) JavaScript components =

Slide 22

Slide 22 text

24 Client Side Logic is generic Presentation logic only. It enhances HTML HTML CSS Content Layout JavaScript Presentation logic

Slide 23

Slide 23 text

Progressive Enhancement 25 A web page needs to work without graphical elements, CSS and JS This makes sure, our page will even work under unfavorable circumstances We also lay the foundation for accessibility Doesn't mean that everything needs to work without CSS and JavaScript It means that the fundamental functionality of our web page works with HTML only Every thing that goes beyond that is seen as an enhancement

Slide 24

Slide 24 text

26 http://rocair.herokuapp.com

Slide 25

Slide 25 text

Danke! Fragen? 27 Lucas Dohmen [email protected] +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