Slide 1

Slide 1 text

@ChrisFerdinandi GoMakeThings.com Vanilla JS for Beginners

Slide 2

Slide 2 text

$ @ChrisFerdinandi

Slide 3

Slide 3 text

JSWTF!?!

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

VanillaJSGuidebook.com

Slide 14

Slide 14 text

This is for…

Slide 15

Slide 15 text

who don’t really know JavaScript jQuery Developers

Slide 16

Slide 16 text

Learning vanilla JavaScript helps you write better jQuery.

Slide 17

Slide 17 text

(but don’t know where to start) JavaScript Frameworks People who want to learn other

Slide 18

Slide 18 text

Rat Race Opt out of the JavaScript framework

Slide 19

Slide 19 text

and more reliable websites Faster

Slide 20

Slide 20 text

and easier JavaScript experience Simpler

Slide 21

Slide 21 text

CHALLENGES?

Slide 22

Slide 22 text

1 Vanilla JavaScript APIs 2 Cross-Browser Compatibility 4 Putting it All Together 3 Debugging

Slide 23

Slide 23 text

Slides & Downloads GoMakeThings.com/talks

Slide 24

Slide 24 text

Vanilla JavaScript APIs 1

Slide 25

Slide 25 text

ECMAScript 5 (ES5) (thanks jQuery!)

Slide 26

Slide 26 text

DEMO TIME!

Slide 27

Slide 27 text

Cross-Browser Compatibility 2

Slide 28

Slide 28 text

Support is not the same as optimization http://bradfrost.com/blog/mobile/support-vs-optimization/

Slide 29

Slide 29 text

A progressive enhancement technique Cutting the Mustard Photo Credit: https://www.flickr.com/photos/39160147@N03/26996085710/ http://responsivenews.co.uk/post/18948466399/cutting-the-mustard

Slide 30

Slide 30 text

var supports = 'querySelector' in document && 'addEventListener' in window; if ( supports ) { // Codes goes here... } // or... if ( !supports ) return;

Slide 31

Slide 31 text

Browser Compatibility • IE9+ • Firefox 3.5+ • Opera 9+ (and probably further back) • Safari 4+ • Chrome 1+ (I think) • iPhone and iPad iOS1+ • Android phone and tablets 2.1+ • Blackberry OS6+ • Windows 7.5+ (new Mango version) • Mobile Firefox (all the versions we tested) • Opera Mobile (all the versions we tested)

Slide 32

Slide 32 text

Don’t hide content until JavaScript loads.

Slide 33

Slide 33 text

.collapse.active .collapse.active { display: block; } .collapse { display: none; } .collapse Show

Slide 34

Slide 34 text

document.documentElement.className += ' js-accordion'; .collapse .js-accordion .collapse { display: none; } .collapse .js-accordion

Slide 35

Slide 35 text

Debugging 3

Slide 36

Slide 36 text

Your code will break. A lot.

Slide 37

Slide 37 text

Use Strict Mode

Slide 38

Slide 38 text

“Strict mode makes several changes to normal JavaScript semantics. First, strict mode eliminates some JavaScript silent errors by changing them to throw errors.” https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode

Slide 39

Slide 39 text

'use strict';

Slide 40

Slide 40 text

Putting it all together 4

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

A project Invisible Ink

Slide 43

Slide 43 text

What now?

Slide 44

Slide 44 text

{ } Vanilla JS

Slide 45

Slide 45 text

Pick a Project

Slide 46

Slide 46 text

Project Ideas • Toggle Tabs • Modals • Save Form Data • Toggle Password Visibility • Make Content the Same Height • Generate a Table of Contents

Slide 47

Slide 47 text

No content

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

VanillaJSGuidebook.com

Slide 50

Slide 50 text

?

Slide 51

Slide 51 text

Vanilla JS Crash Course GoMakeThings.com/crash-course

Slide 52

Slide 52 text

Thank You!