Slide 1

Slide 1 text

@cassilup // tim .js Organizer // 3PG Senior Dev Working with the DOM & Living to Tell

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

1990s Henry Ford?

Slide 4

Slide 4 text

1990s Browser Wars

Slide 5

Slide 5 text

1990s Browser Wars

Slide 6

Slide 6 text

1990s Browser Wars Netscape vs. Internet Explorer

Slide 7

Slide 7 text

1990s Browser Wars Netscape vs. Internet Explorer JScript vs. Javascript

Slide 8

Slide 8 text

DOM Level 0 / HTML 4 1995 Intermediate DOM / DHTML,
 ECMAScript 1997 1998 DOM Level 1 / weak browser upgrades 2000 DOM Level 2 / getElementById 1994 W3C 2004 DOM Level 3 / keyboard DOM Level 4 / Draft 2014

Slide 9

Slide 9 text

What exactly is the DOM?

Slide 10

Slide 10 text

css-tricks.com/dom

Slide 11

Slide 11 text

css-tricks.com/dom

Slide 12

Slide 12 text

css-tricks.com/dom

Slide 13

Slide 13 text

The Document Object Model (DOM) is a platform- and language-neutral interface that will allow programs and scripts to dynamically access and update the content, structure and style of documents. (w3.org/DOM)

Slide 14

Slide 14 text

TL; DR The DOM is an API

Slide 15

Slide 15 text

wikipedia.org DOM

Slide 16

Slide 16 text

wikipedia.org DOM BOM

Slide 17

Slide 17 text

• Interact with it (JS, CSS) wikipedia.org

Slide 18

Slide 18 text

• Interact with it (JS, CSS) • Nodes (elements) wikipedia.org

Slide 19

Slide 19 text

• Interact with it (JS, CSS) • Nodes (elements) • Parents & Children (inheritance) wikipedia.org

Slide 20

Slide 20 text

• Interact with it (JS, CSS) • Nodes (elements) • Parents & Children (inheritance) • Events wikipedia.org

Slide 21

Slide 21 text

• Interact with it (JS, CSS) • Nodes (elements) • Parents & Children (inheritance) • Events • ≠ HTML (a markup
 language that enables
 representing a certain 
 kind of DOM in text.) wikipedia.org

Slide 22

Slide 22 text

• Designed for C, C++, JAVA, JavaScript and others.

Slide 23

Slide 23 text

• Designed for C, C++, JAVA, JavaScript and others. • "A camel is a horse designed by committee.” (source)

Slide 24

Slide 24 text

• Designed for C, C++, JAVA, JavaScript and others. • "A camel is a horse designed by committee.” (source) • Implemented in each browser, differently. (!!)

Slide 25

Slide 25 text

• Designed for C, C++, JAVA, JavaScript and others. • "A camel is a horse designed by committee.” (source) • Implemented in each browser, differently. (!!) quirksmode.org

Slide 26

Slide 26 text

quirksmode.org

Slide 27

Slide 27 text

Headaches! (link) • Getting the Cursor Position • Getting the Size of the Viewport, or Browser Window • IE, background transparent click (and many many many others) • DOM Ready (38-line solution) Solutions? • jQuery, • MooTools, • Prototype, • CSS Resets.

Slide 28

Slide 28 text

Whatever it is you want to do, you need to do it with DOM!

Slide 29

Slide 29 text

What did I want to do?

Slide 30

Slide 30 text

What did I want to do? the quick brown fox jumps over the lazy dog

Slide 31

Slide 31 text

What did I want to do? the quick brown fox jumps over the lazy dog

Slide 32

Slide 32 text

1. Default Behaviour the quick brown fox jumps over the lazy dog
the quick brown fox jumps over the lazy dog

Slide 33

Slide 33 text

2. Add CSS the quick brown fox jumps over the lazy dog
the quick brown fox jumps over the lazy dog

Slide 34

Slide 34 text

3. Uppercase & Line Breaks THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG
THE QUICK
BROWN
FOX
JUMPS OVER THE
LAZY DOG

Slide 35

Slide 35 text

4. Separate Lines THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG
THE QUICK
BROWN
FOX
JUMPS OVER THE
LAZY DOG

Slide 36

Slide 36 text

5. Calculate Line Width THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG

Slide 37

Slide 37 text

5. Calculate Line Width THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG

Slide 38

Slide 38 text

6. Do the Math (Rule of Three, anybody?) THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG

Slide 39

Slide 39 text

6. Do the Math (Rule of Three, anybody?) THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG

Slide 40

Slide 40 text

Voilá! THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG

Slide 41

Slide 41 text

Voilá! FOOD & BEVERAGE

Slide 42

Slide 42 text

Voilá! WORLD WAR II Chrome

Slide 43

Slide 43 text

Voilá! WORLD WAR II Firefox

Slide 44

Slide 44 text

Voilá! WORLD WAR II I E

Slide 45

Slide 45 text

Voilá! WORL D WAR II Voilá!?!? Safari

Slide 46

Slide 46 text

Voilá! Voilá!?!?

Slide 47

Slide 47 text

No content

Slide 48

Slide 48 text

WORL D WAR II Safari Tricky Hack

Slide 49

Slide 49 text

Tricky Hack WORLD WAR II Safari

Slide 50

Slide 50 text

Solution WORL D WAR II Safari WORLD WAR II Chrome Dynamically adjust font-size

Slide 51

Slide 51 text

Advantages • OS-agnostic • Infinite font support • Dynamic rendering Disvantages • Performance issues

Slide 52

Slide 52 text

Advantages • OS-agnostic • Infinite font support • Dynamic rendering Disvantages • Performance issues - use cookies!

Slide 53

Slide 53 text

Optimize TIM.JS ROCKS

Slide 54

Slide 54 text

Optimize TIM.J S ROCK S

Slide 55

Slide 55 text

Optimize TIM. JS ROC KS

Slide 56

Slide 56 text

Optimize TIM.J S ROCK S

Slide 57

Slide 57 text

Optimize TIM.JS ROCKS

Slide 58

Slide 58 text

cramify . JS

Slide 59

Slide 59 text

https://github.com/cassilup/cramify.js Try Fork Contribute cramify . JS

Slide 60

Slide 60 text

AngularJS
 Don’t touch the DOM!
 ReactJS
 Virtual DOM. What the Others did. (L.O.S.T. anybody?)

Slide 61

Slide 61 text

Thank You @cassilup // tim .js Organizer // 3PG Senior Dev

Slide 62

Slide 62 text

No content