Slide 1

Slide 1 text

@stopsatgreen WEB COMPONENTS What, Why, How, When #WCLDN, 04/03

Slide 2

Slide 2 text

@stopsatgreen @stopsatgreen Peter Gasston broken-links.com

Slide 3

Slide 3 text

@stopsatgreen WEB COMPONENTS

Slide 4

Slide 4 text

@stopsatgreen http://en.wikipedia.org/wiki/H%C3%A9lio_Oiticica

Slide 5

Slide 5 text

@stopsatgreen

Slide 6

Slide 6 text

@stopsatgreen WHAT?

Slide 7

Slide 7 text

@stopsatgreen “The component model for the Web.”

Slide 8

Slide 8 text

@stopsatgreen A suite of technologies for making reusable UI controls or services.

Slide 9

Slide 9 text

@stopsatgreen Fundamental change to the way we build the Web.

Slide 10

Slide 10 text

@stopsatgreen

Slide 11

Slide 11 text

@stopsatgreen

Slide 12

Slide 12 text

@stopsatgreen

Slide 13

Slide 13 text

@stopsatgreen ® The Lego Group

Slide 14

Slide 14 text

@stopsatgreen Custom Elements + Shadow DOM + HTML Imports + Templates = Web Components

Slide 15

Slide 15 text

@stopsatgreen WHY?

Slide 16

Slide 16 text

@stopsatgreen

Slide 17

Slide 17 text

@stopsatgreen OOCSS BEM Java Applets Dynamic Drive React Ember jQuery UI Bootstrap Web Components

Slide 18

Slide 18 text

@stopsatgreen W3C WHATWG

Slide 19

Slide 19 text

@stopsatgreen

Slide 20

Slide 20 text

@stopsatgreen • jQuery : querySelector(), classList • Modernizr : @supports • Sass : --custom-properties()

Slide 21

Slide 21 text

@stopsatgreen Let us make the tools we need.

Slide 22

Slide 22 text

@stopsatgreen #extendthewebforward http://extensiblewebmanifesto.org/

Slide 23

Slide 23 text

@stopsatgreen

Slide 24

Slide 24 text

@stopsatgreen http://msdn.microsoft.com/library/ie/ms531426.aspx

Slide 25

Slide 25 text

@stopsatgreen

Slide 26

Slide 26 text

@stopsatgreen

Slide 27

Slide 27 text

@stopsatgreen

Slide 28

Slide 28 text

@stopsatgreen meaningful naming + modularisation + encapsulation + sharing = web components

Slide 29

Slide 29 text

@stopsatgreen HOW?

Slide 30

Slide 30 text

@stopsatgreen Custom Elements

Slide 31

Slide 31 text

@stopsatgreen document.registerElement('fun-times');

Slide 32

Slide 32 text

@stopsatgreen = HTMLElement = HTMLUnknownElement

Slide 33

Slide 33 text

@stopsatgreen fun-times:unresolved {…}

Slide 34

Slide 34 text

@stopsatgreen proto = Object.create(HTMLElement.prototype); proto.hooray = function() {…}; document.registerElement('fun-times',
 { prototype: proto }); funTimes = document.querySelector('fun-times');
 funTimes.hooray();

Slide 35

Slide 35 text

@stopsatgreen proto = Object.create(HTMLElement.prototype); proto.createdCallback = function() {…}; document.registerElement('fun-times',
 { prototype: proto });

Slide 36

Slide 36 text

@stopsatgreen proto = Object.create(HTMLButtonElement.prototype); proto.hooray = function() {…}; document.registerElement('fun-times', { prototype: proto, extends: 'button' });

Slide 37

Slide 37 text

@stopsatgreen Shadow DOM

Slide 38

Slide 38 text

@stopsatgreen

Slide 39

Slide 39 text

@stopsatgreen

Slide 40

Slide 40 text

@stopsatgreen var root = foo.createShadowRoot();
 root.innerHTML = '
';

Slide 41

Slide 41 text

@stopsatgreen Templates

Slide 42

Slide 42 text

@stopsatgreen … var party = document.getElementById('party'); var partyContent = party.content;

Slide 43

Slide 43 text

@stopsatgreen var funTimes = document.querySelector('fun-times'); var proto = Object.create(HTMLElement.prototype); proto.hooray = function() {…}; proto.createdCallback = function() { var party = document.getElementById('party'); var clone = document.importNode(party.content,true); var root = funTimes.createShadowRoot(); root.appendChild(clone); } document.registerElement('fun-times', { prototype: proto });

Slide 44

Slide 44 text

@stopsatgreen HTML Imports

Slide 45

Slide 45 text

@stopsatgreen

Slide 46

Slide 46 text

@stopsatgreen http://leafletjs.com/

Slide 47

Slide 47 text

@stopsatgreen

Slide 48

Slide 48 text

@stopsatgreen But it’s not all rosy.

Slide 49

Slide 49 text

@stopsatgreen The is="" pattern. https://lists.w3.org/Archives/Public/public-webapps/2015JanMar/0206.html

Slide 50

Slide 50 text

@stopsatgreen

Slide 51

Slide 51 text

@stopsatgreen document.registerElement('fun-times'); var funRoot = funTimes.createShadowRoot(); funRoot.innerHTML = '…';

Slide 52

Slide 52 text

@stopsatgreen HTML Imports have huge potential for performance problems…

Slide 53

Slide 53 text

@stopsatgreen /path/to/library.min.js
 /path/to/a/library.min.js

Slide 54

Slide 54 text

@stopsatgreen 
 


Slide 55

Slide 55 text

@stopsatgreen … so Firefox won’t implement.

Slide 56

Slide 56 text

@stopsatgreen WHEN?

Slide 57

Slide 57 text

@stopsatgreen Browser Custom Elements Shadow DOM HTML Imports Template Who knows? ‘Under consideration’ ✓ ✓ ✓ ✓ ✓ ✗ ✓ ✓ ✓ http://jonrimmer.github.io/are-we-componentized-yet/

Slide 58

Slide 58 text

@stopsatgreen Web Components will happen. Maybe not in this form, but the concept is solid.

Slide 59

Slide 59 text

@stopsatgreen

Slide 60

Slide 60 text

webcomponents.js (polyfills) Polymer Core Bosonic Core Elements Brick Paper Elements Elements polymer-project.org | brick.mozilla.io | bosonic.github.io | webcomponents.org Standard

Slide 61

Slide 61 text

@stopsatgreen Web Components vs. React (etc)

Slide 62

Slide 62 text

@stopsatgreen Everything Useful Useful & well-made Crap http://en.wikipedia.org/wiki/Sturgeon%27s_law

Slide 63

Slide 63 text

@stopsatgreen Sturgeon’s Law: 90% of everything is crap

Slide 64

Slide 64 text

@stopsatgreen http://addyosmani.com/first/

Slide 65

Slide 65 text

@stopsatgreen http://www.paciellogroup.com/blog/2014/09/web-components-punch-list/

Slide 66

Slide 66 text

@stopsatgreen Web Components are for you to drive the future of the web. Please drive responsibly.

Slide 67

Slide 67 text

@stopsatgreen THE END