Progressive Web Components GOTO Berlin 2016 Frederik Dohr, @fnd - - PowerPoint PPT Presentation

progressive web components
SMART_READER_LITE
LIVE PREVIEW

Progressive Web Components GOTO Berlin 2016 Frederik Dohr, @fnd - - PowerPoint PPT Presentation

Progressive Web Components GOTO Berlin 2016 Frederik Dohr, @fnd Stefan Tilkov, @stilkov History repeating Web CORBA WS-* REST Whats the client side analogy? Web app 2) Web service 1) > Uses browser as runtime >


slide-1
SLIDE 1
slide-2
SLIDE 2

Progressive Web Components

Frederik Dohr, @fnd
 Stefan Tilkov, @stilkov GOTO Berlin 2016

slide-3
SLIDE 3

History repeating …

CORBA Web WS-* REST

slide-4
SLIDE 4

What’s the client side analogy?

slide-5
SLIDE 5

“Web service”1)

> Use HTTP as transport > Ignore verbs > Ignores URIs > Expose single “endpoint” > Fails to embrace the Web

1) in the SOAP/WSDL sense

> Uses browser as runtime > Ignores forward, back, refresh > Does not support linking > Exposes monolithic “app” > Fails to embrace the browser

2) built as a careless SPA

“Web app”2)

slide-6
SLIDE 6

Desktop-style single-page apps: The browser’s WS-*

slide-7
SLIDE 7

Assumption: JS-centric web apps can
 be as good as native apps They shouldn’t be as bad!

slide-8
SLIDE 8

Simple two-step secret to improving the performance of any website, according to Maciej Ceglowski (@baconmeteor):

“1. Make sure that the most important
 elements of the page download and
 render fjrst.

  • 2. Stop there.”

http://idlewords.com/talks/website_obesity.htm

slide-9
SLIDE 9

JavaScript framework tax

bloat complexity dependency technical debt

slide-10
SLIDE 10

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-11
SLIDE 11

ROCA: Resource-oriented Client Architecture http:/ /roca-style.org

slide-12
SLIDE 12

Framework? We don’t need no stinking framework

Maybe we do

slide-13
SLIDE 13

Framework benefjts

folklore architecture opinion community skills components component model

slide-14
SLIDE 14

🙐

slide-15
SLIDE 15

SPAs : web development :: Trump : democracy

slide-16
SLIDE 16

Any suffjciently complicated JavaScript client application contains an ad-hoc, informally-specifjed, bug-ridden, slow implementation of half a browser.

— Stefan Tilkov, with apologies to Phillip Greenspun

slide-17
SLIDE 17

Hard to put into words how utterly broken JS-fjrst web development is. So many parts of the system work against you when you take the reins.

— Alex Russell (@slightlylate)

slide-18
SLIDE 18

Browser Platform

Component

JavaScript Framework

Component Component Component

date picker task list shopping cart media player Application

slide-19
SLIDE 19

< >
 


slide-20
SLIDE 20

<video >
 


slide-21
SLIDE 21

<video src="bunny.mp4" controls>
 


slide-22
SLIDE 22

<video src="bunny.mp4" controls>
 <track kind="subtitles" …>
 </video>

play / pause .play() / .pause()

slide-23
SLIDE 23

source: Big Buck Bunny

slide-24
SLIDE 24

The browser is the framework #UseThePlatform

slide-25
SLIDE 25

Browser Platform

Component

Application JavaScript Framework

Component Component Component

slide-26
SLIDE 26

😲 😲

Browser Platform Application JavaScript Framework

Component Component

slide-27
SLIDE 27

Browser Platform

Component Component Component Component

Application

Component

slide-28
SLIDE 28

Component

<audio src="meow.mp4" controls>
 


Browser Platform

Component Component Component

Application

slide-29
SLIDE 29

Component

Browser Platform

Component Component Component

Glue Code Application

slide-30
SLIDE 30

<input type="text" class="date"> $("input.date").datepicker();

slide-31
SLIDE 31

<div class="tabs"> <ul> <li> <a href="#about">About</a> … <li> <a href="#comments">Discussion</a> </ul> <p id="about">lorem ipsum dolor sit amet</p> … <ol id="comments"> … </ol> </div>

$(".tabs").tabs();

slide-32
SLIDE 32

<div class="tabs"> <ul> <li> <a href="#about">About</a> … <li> <a href="#comments">Discussion</a> </ul> <p id="about">lorem ipsum dolor sit amet</p> … <ol id="comments"> … </ol> </div>

$(".tabs").tabs();

slide-33
SLIDE 33

<div class="tabs"> <ul> <li> <a href="#about">About</a> … <li> <a href="#comments">Discussion</a> </ul> <p id="about">lorem ipsum dolor sit amet</p> … <ol id="comments"> … </ol> </div>

$(".tabs").tabs(); 🎊 Unobtrusive JavaScript 🎊

slide-34
SLIDE 34

Component

Browser Platform

Component Component Component

Glue Code

HTML JS CSS HTML JS CSS HTML JS CSS HTML JS CSS

👍 Progressive Enhancement 👎

slide-35
SLIDE 35

Component

Browser Platform

Component Component Component

Glue Code

HTML JS CSS HTML JS CSS HTML JS CSS HTML JS CSS

👍 Progressive Enhancement 👎 Progressive enhancement is not about dealing with old browsers, it's about dealing with new browsers.

— Jeremy Keith (@adactio)

slide-36
SLIDE 36

<div class="tabs"> <ul> <li> <a href="#about">About</a> … <li> <a href="#comments">Discussion</a> </ul> <p id="about">lorem ipsum dolor sit amet</p> … <ol id="comments"> … </ol> </div>

$(".tabs").tabs();

slide-37
SLIDE 37

<tab-nav> <ul> <li> <a href="#about">About</a> … <li> <a href="#comments">Discussion</a> </ul> </tab-nav> <p id="about">lorem ipsum dolor sit amet</p> … <ol id="comments"> … </ol>

$(".tabs").tabs();

slide-38
SLIDE 38

<tab-nav> <ul> <li> <a href="#about">About</a> … <li> <a href="#comments">Discussion</a> </ul> </tab-nav> <tab-contents> <p id="about">lorem ipsum dolor sit amet</p> … <ol id="comments"> … </ol> </tab-contents>

$(".tabs").tabs();

slide-39
SLIDE 39

<ul is="tab-nav"> <li> <a href="#about">About</a> … <li> <a href="#comments">Discussion</a> </ul> <tab-contents> <p id="about">lorem ipsum dolor sit amet</p> … <ol id="comments"> … </ol> </tab-contents>

$(".tabs").tabs();

slide-40
SLIDE 40

<ul is="tab-nav"> <li> <a href="#about">About</a> … <li> <a href="#comments">Discussion</a> </ul> <tab-contents> <p id="about">lorem ipsum dolor sit amet</p> … <ol id="comments"> … </ol> </tab-contents>

📅 Custom Elements

📅

slide-41
SLIDE 41

customElements.define("task-list");

slide-42
SLIDE 42

customElements.define("task-list", TaskList); class TaskList extends HTMLElement {}

slide-43
SLIDE 43

customElements.define("task-list", TaskList); class TaskList extends HTMLElement { constructor() { // element created or upgraded super(); … } connectedCallback() { // element inserted into the DOM … } disconnectedCallback() { // element removed from the DOM … } }

slide-44
SLIDE 44

customElements.define("task-list", TaskList); class TaskList extends HTMLElement { … attributeChangedCallback(attrName, oldVal, newVal) { … } static get observedAttributes() { return ["theme"]; } }

slide-45
SLIDE 45

customElements.define("task-list", TaskList); class TaskList extends HTMLElement { … connectedCallback() { let obs = new MutationObserver(this.onChange);

  • bs.observe(this, { childList: true, subtree: true });

} …

  • nChange() {

… } }

slide-46
SLIDE 46

customElements.define("task-list", TaskList); class TaskList extends HTMLElement { … connectedCallback() { let shadowRoot = this.attachShadow({ mode: "open" }); shadowRoot.innerHTML = "<canvas></canvas>"; … } … }

📅 Shadow DOM

📅

slide-47
SLIDE 47

Component

Browser Platform

Component Component Component

Glue Code

slide-48
SLIDE 48

Component

Browser Platform

Component Component Component Glue Code

📅 Custom Elements

📅

Boring Is Good

slide-49
SLIDE 49

Component

Browser Platform

Component Component Glue Code Component

image source: Openclipart/atlantis

slide-50
SLIDE 50

Component

Browser Platform

Component Component Glue Code Component

image source: Openclipart/atlantis

Style Guides & Component Libraries

slide-51
SLIDE 51

Wrap-up

slide-52
SLIDE 52

Backend platform goals

> As few assumptions as possible > No implementation dependencies > Small interface surface > Based on standards > Parallel development > Independent deployment > Autonomous operations

Backend Platform

slide-53
SLIDE 53

What’s the frontend platform analogy?

> As few assumptions as possible > No implementation dependencies > Small interface surface > Based on standards > Parallel development > Independent deployment > Autonomous operations

Backend Platform Frontend Platform

slide-54
SLIDE 54

The browser as a platform

> Independent applications > Loosely coupled > Separately deployable > Based on standard platform > Updated on the fly > Any device

Backend Platform Frontend Platform

slide-55
SLIDE 55

Summary

slide-56
SLIDE 56

Embracing the browsers constraints provides benefjts

slide-57
SLIDE 57

JS Frameworks provide a proprietary architecture

slide-58
SLIDE 58

Web components ofger a standardized way to get the best

  • f both worlds
slide-59
SLIDE 59

Frederik Dohr fnd@innoq.com

innoQ Deutschland GmbH
  • Krischerstr. 100
40789 Monheim am Rhein Germany Phone: +49 2173 3366-0 innoQ Schweiz GmbH
  • Gewerbestr. 11
CH-6330 Cham Switzerland Phone: +41 41 743 0116

www.innoq.com

Ohlauer Straße 43 10999 Berlin Germany Phone: +49 2173 3366-0
  • Ludwigstr. 180E
63067 Ofgenbach Germany Phone: +49 2173 3366-0 Kreuzstraße 16
 80331 München Germany Phone: +49 2173 3366-0

Thank you – that’s all we have. @fnd

Stefan Tilkov
 stefan.tilkov@innoq.com

@stilkov

slide-60
SLIDE 60