Top Banner
A Simpler Web Architecture. Gustaf Nilsson Kotte @gustaf_nk
40

A Simpler Web App Architecture (jDays 2016)

Feb 14, 2017

Download

Technology

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: A Simpler Web App Architecture (jDays 2016)

A SimplerWeb Architecture.

Gustaf Nilsson Kotte @gustaf_nk

Page 2: A Simpler Web App Architecture (jDays 2016)

“server-side vs client-side”

static web pages vs dynamic web app?

no!

either/or → both/and

Page 3: A Simpler Web App Architecture (jDays 2016)

Elevator pitch

Demonstrate client-side techniques that makes server-side rendering a feasible choice for your web applications.

Page 4: A Simpler Web App Architecture (jDays 2016)

General sanity checks

Does the tool add value?What are the requirements?

Page 5: A Simpler Web App Architecture (jDays 2016)

what is your foundation?

Page 6: A Simpler Web App Architecture (jDays 2016)

client-side web benefits

independent deploys

partial updates

caching

cross-team widgets

enables rich interactions

Page 7: A Simpler Web App Architecture (jDays 2016)

client-side web challenges

technological progress → device diversity

time-to-first-render (✓ isomorphic javascript)

“EnhanceConf - Forbes Lindesay - Server Side Rendering”, https://m.youtube.com/watch?v=CBnd3EzIZCo

interoperability/evolvability

rate of change

Page 8: A Simpler Web App Architecture (jDays 2016)

techniques

Page 9: A Simpler Web App Architecture (jDays 2016)

techniques

web server enables server-side web (architectural foundation)

pjax → partial updates (HTML views over ajax)

client-side includes (caching and reusable content)

server-side driven client refreshes

custom elements → shared widgets

Page 10: A Simpler Web App Architecture (jDays 2016)

web server

Page 11: A Simpler Web App Architecture (jDays 2016)

“a web server that uses an API”

a.k.a...

gateway web server

web frontend server

HTML serving API gateway

web backend for frontend (BFF)

Page 12: A Simpler Web App Architecture (jDays 2016)
Page 13: A Simpler Web App Architecture (jDays 2016)

server-side web

✓ independent deploys (gateway web server)

Page 14: A Simpler Web App Architecture (jDays 2016)

pjax

Page 15: A Simpler Web App Architecture (jDays 2016)

pjax

jquery-pjax (GitHub 2011)https://github.com/defunkt/jquery-pjax

pushState ajax

~500 LOC (not counting comments)

jQuery dependency

Page 16: A Simpler Web App Architecture (jDays 2016)

jquery-pjax

Page 17: A Simpler Web App Architecture (jDays 2016)

jquery-pjax

multiple containers (be careful)

don’t overlap event handlers

rewrite in progress (very exciting)https://github.com/defunkt/jquery-pjax/issues/498

Page 18: A Simpler Web App Architecture (jDays 2016)

demo: enterprise

todos

Page 19: A Simpler Web App Architecture (jDays 2016)

server-side web

✓ independent deploys (gateway web server)

✓ partials updates (pjax)

Page 20: A Simpler Web App Architecture (jDays 2016)

client-side includes

Page 21: A Simpler Web App Architecture (jDays 2016)

client-side includes

hinclude.jshttps://github.com/mnot/hinclude/

2005 by Mark Nottingham (@mnot)https://en.wikipedia.org/wiki/Mark_Nottingham

~150 LOC (not counting comments)

Page 22: A Simpler Web App Architecture (jDays 2016)

hinclude.js

Page 23: A Simpler Web App Architecture (jDays 2016)

h-include.js

custom element version of hinclude.jshttps://github.com/mnot/hinclude/pull/46

custom element polyfill: 3KBhttps://github.com/WebReflection/document-register-element

includes in includes, etc etc

Page 24: A Simpler Web App Architecture (jDays 2016)

server-side driven client-side refreshes

shared list of known domain events

server:

client:

Page 25: A Simpler Web App Architecture (jDays 2016)

demo

Page 26: A Simpler Web App Architecture (jDays 2016)

server-side web

✓ independent deploys (gateway web server)

✓ partials updates (pjax + client-side includes)

✓ better caching (client-side includes)

Page 27: A Simpler Web App Architecture (jDays 2016)

widgets

Page 28: A Simpler Web App Architecture (jDays 2016)

widgets

internal/external

dependencies?

either need to agree (now and later) or bring their own (page weight)

what to do?

Page 29: A Simpler Web App Architecture (jDays 2016)

→ widgets

separate content from execution

code repository for custom elements

no dependencies

custom element enhances content

think about compatibility

Page 30: A Simpler Web App Architecture (jDays 2016)

demo

Page 31: A Simpler Web App Architecture (jDays 2016)

server-side web

✓ independent deploys (gateway web server)

✓ partials updates (pjax + client-side includes)

✓ better caching (client-side includes)

✓ cross-team widgets (client-side includes + custom elements)

Page 32: A Simpler Web App Architecture (jDays 2016)

summary

Page 33: A Simpler Web App Architecture (jDays 2016)

techniques

web server enables server-side web (architectural foundation)

pjax → partial updates (HTML views over ajax)

client-side includes (caching and reusable content)

server-side driven client refreshes

custom elements → shared widgets (free from dependencies)

Page 34: A Simpler Web App Architecture (jDays 2016)

example scenario: static e-commerce site

Page 35: A Simpler Web App Architecture (jDays 2016)

example scenario: dynamic web app

Page 36: A Simpler Web App Architecture (jDays 2016)

client-side web benefits

independent deploys

partials updates

better caching

cross-team widgets

enables rich interactions

Page 37: A Simpler Web App Architecture (jDays 2016)

server-side web

✓ independent deploys (gateway web server)

✓ partials updates (pjax + client-side includes)

✓ better caching (client-side includes)

✓ cross-team widgets (client-side includes + custom elements)

~ enables rich interactions (do you really need it?)

Page 38: A Simpler Web App Architecture (jDays 2016)

General sanity checks

Does the tool add value?What are the requirements?

Page 39: A Simpler Web App Architecture (jDays 2016)

why is server-side web simpler?

(technological progress → device diversity)

less moving parts

working with the browser

better evolvability

lower rate of change

Page 40: A Simpler Web App Architecture (jDays 2016)

thank you! thank you! thank you! thank you! thank you! thank you! thank you! thank you! thank you! thank you! thank you! thank you! thank you! thank you! thank you! thank you! thank you! thank you! thank you! thank you! thank you! thank you! thank you! thank you! thank you! thank you! thank you! thank you! thank you! thank you! thank you! (@gustaf_nk)https://github.com/gustafnk/simple-web-architecture-examplehttps://simple-web-enterprise-todos.herokuapp.com/