professional frontend engineering

201

Click here to load reader

Upload: nate-koechley

Post on 27-Jan-2015

35.410 views

Category:

Technology


6 download

DESCRIPTION

Here are the slides from my talk at @media in London two weeks ago titled "Professional Frontend Engineering." I had four goals for the talk. Put a stake in the ground. Reiterate our values. Advocate the discipline. Nurture a healthy Web.The goals were threaded throughout the four sections of the talk:: Historical Perspective Our Beliefs & Principles Knowledge Areas & Best Practices Why It All MattersThe professionalization of frontend engineering is a topic I'm passionate about. I think it is critical to the advancement of the Internet. Presented May 30th, 2008, in London at the @media conference in the plenary opening day two.

TRANSCRIPT

Page 1: Professional Frontend Engineering

Professional Frontend Engineering

Nate KoechleySenior Frontend Engineer

Yahoo!

[email protected] | developer.yahoo.com/yui nate.koechley.com/blog | “natekoechley”

Page 2: Professional Frontend Engineering

Why this topic?

Page 3: Professional Frontend Engineering
Page 4: Professional Frontend Engineering

• Put a stake in the ground.

• Reiterate our values.

• Advocate the discipline.

• Nurture a healthy Web.

Page 5: Professional Frontend Engineering
Page 6: Professional Frontend Engineering
Page 7: Professional Frontend Engineering

Historical Perspective

Page 8: Professional Frontend Engineering

Historical Perspective

Our Beliefs& Principles

Page 9: Professional Frontend Engineering

Historical Perspective

Our Beliefs& Principles

Knowledge Areas & Best

Practices

Page 10: Professional Frontend Engineering

Historical Perspective

Why It All Matters

Our Beliefs& Principles

Knowledge Areas & Best

Practices

Page 11: Professional Frontend Engineering

Historical Perspective

Page 12: Professional Frontend Engineering
Page 13: Professional Frontend Engineering
Page 14: Professional Frontend Engineering
Page 15: Professional Frontend Engineering
Page 16: Professional Frontend Engineering
Page 17: Professional Frontend Engineering
Page 18: Professional Frontend Engineering
Page 19: Professional Frontend Engineering

Year = 2001

Page 20: Professional Frontend Engineering

Age = 7 years

Page 21: Professional Frontend Engineering

Employees = 3000

Page 22: Professional Frontend Engineering

Frontend Engineers = 0

Page 23: Professional Frontend Engineering

So?

Page 24: Professional Frontend Engineering

2001First frontend engineering

specialists hired.

Page 25: Professional Frontend Engineering

2008~700 professional frontend

engineers spread across Y! offices worldwide.

And hiring!!!

Page 26: Professional Frontend Engineering

2001Font tags & nested tables.

Static interface.

Page 27: Professional Frontend Engineering

2008Semantic & accessible markup.

Rich DHTML & Ajax behavior.

More content. Same fast speed.

Page 28: Professional Frontend Engineering

2001Available and accessible to

everyone.

Page 29: Professional Frontend Engineering

2008Available and accessible to

everyone.

Page 30: Professional Frontend Engineering

2001Plain but predictable.

Page 31: Professional Frontend Engineering

2008Highly visual and adaptive, but

still dependable.

Page 32: Professional Frontend Engineering

2001Modest user expectations.

Page 33: Professional Frontend Engineering

2008Sophisticated, broad, and

non-trivial user expectations.

Page 34: Professional Frontend Engineering

2001Intersection of design and development still vague.

Page 35: Professional Frontend Engineering

NowProfessional Frontend

Engineers focused at the intersection of design and

development is a best practice.

Page 36: Professional Frontend Engineering

—Irene Au, SVP of UED at Yahoo!

Page 37: Professional Frontend Engineering

“In 2001, with developments in advanced JavaScript and DHTML, we knew the web experience would evolve beyond the static

pages we were producing. We brought in web developers to help us pioneer Yahoo’s offerings

to include a more dynamic, interactive experience for our users.”

—Irene Au, SVP of UED at Yahoo!

Page 38: Professional Frontend Engineering

—Irene Au, SVP of UED at Yahoo!

Page 39: Professional Frontend Engineering

“... Another motivation was to bring in a disciplined frontend programming practice to Yahoo. Before then, the

presentation, behavior, and structure of our pages were not separate, which led to many challenges and inefficiencies in designing and developing our products.”

—Irene Au, SVP of UED at Yahoo!

Page 40: Professional Frontend Engineering
Page 41: Professional Frontend Engineering
Page 42: Professional Frontend Engineering

“The Framers of the Web saw browser differences

as beneficial and believed that visitors should

choose how their browser displays the page...”

Page 43: Professional Frontend Engineering
Page 44: Professional Frontend Engineering

“...I wanted more control so I threw my HTML book in the trash and started from scratch.”

Page 45: Professional Frontend Engineering

The Web is still sick.

Page 46: Professional Frontend Engineering

Frontend Engineers are the Web’s Radiologists

Page 47: Professional Frontend Engineering

Question:

What is Frontend Engineering?

Page 48: Professional Frontend Engineering

Answer:

We write software in JavaScript, CSS, and HTML & more...

Page 49: Professional Frontend Engineering

Answer:

We tell browsers what to do.

Page 50: Professional Frontend Engineering

Answer:

We’re responsible for “view source”

Page 51: Professional Frontend Engineering

The Yahoo! Stack

C/C++ Libraries.90% C/C++, 10% PHP

Generic PHP functions & libs100% PHP

Specific PHP biz logic90% PHP, 10% Text

Display logic & APIs50% HTML, 50% PHP

Pages & modules95% HTML, 5% PHP

Page 52: Professional Frontend Engineering

The Yahoo! Stack

C/C++ Libraries.90% C/C++, 10% PHP

Generic PHP functions & libs100% PHP

Specific PHP biz logic90% PHP, 10% Text

Display logic & APIs50% HTML, 50% PHP

Pages & modules95% HTML, 5% PHP

Backend

Frontend

Page 53: Professional Frontend Engineering

The Yahoo! Stack

C/C++ Libraries.90% C/C++, 10% PHP

Generic PHP functions & libs100% PHP

Specific PHP biz logic90% PHP, 10% Text

Display logic & APIs50% HTML, 50% PHP

Pages & modules95% HTML, 5% PHP

Backend

Frontend

Page 54: Professional Frontend Engineering

SIMPLE?

Page 55: Professional Frontend Engineering

no.

Page 56: Professional Frontend Engineering

server

Page 57: Professional Frontend Engineering

(X)HTML

server

Page 58: Professional Frontend Engineering

(X)HTML

Specification

server

Page 59: Professional Frontend Engineering

(X)HTML

Specification Implementation

server

Page 60: Professional Frontend Engineering

(X)HTML

Specification Implementation

Bugs

server

Page 61: Professional Frontend Engineering

(X)HTML

Specification Implementation

Bugs [ Theory / Practice ]

server

Page 62: Professional Frontend Engineering

Dat

a Tr

ansp

ort

data

: cus

tom

, xm

l,

js

onbe

havi

or: j

sm

ixed

: new

xht

ml

(X)HTML DOM JavaScript

Specification Implementation

Bugs [ Theory / Practice ]

BOM API

DOM API

CSS

server

Page 63: Professional Frontend Engineering

Dat

a Tr

ansp

ort

data

: cus

tom

, xm

l,

js

onbe

havi

or: j

sm

ixed

: new

xht

ml

(X)HTML DOM JavaScript

Specification Implementation

Bugs [ Theory / Practice ]

BOM API

DOM API

CSS

server

Macintosh

Safari Firefox Opera

Windows

OperaIE5, 6, 7 Firefox

Linux, Unix, Mobile

10,000+ UAs

Page 64: Professional Frontend Engineering

Dat

a Tr

ansp

ort

data

: cus

tom

, xm

l,

js

onbe

havi

or: j

sm

ixed

: new

xht

ml,

(X)HTML DOM JavaScript

Specification Implementation

Defects [ Theory / Practice ]

BOM API

DOM API

CSS

server

MacintoshSafari Firefox Opera

WindowsOperaIE5, 6, 7 Firefox

Linux, Unix, Mobile10,000+ UAs

Page 65: Professional Frontend Engineering

Dat

a Tr

ansp

ort

data

: cus

tom

, xm

l,

js

onbe

havi

or: j

sm

ixed

: new

xht

ml,

(X)HTML DOM JavaScript

Specification Implementation

Defects [ Theory / Practice ]

BOM API

DOM API

CSS

server

MacintoshSafari Firefox Opera

WindowsOperaIE5, 6, 7 Firefox

Linux, Unix, Mobile10,000+ UAs

knowledge areas: 7dimensions: x 4

platforms: x 3browsers per platform: x 4

rendering modes: x 2

=672

Page 66: Professional Frontend Engineering
Page 67: Professional Frontend Engineering

usability, internationalization, localization, visual design,

accessibility, information architecture, security, build processes, performance,

benchmarking, devices, portability

Page 68: Professional Frontend Engineering

from Lifted©2007 Pixar Animation Studios

Page 69: Professional Frontend Engineering

Different from Backend because we:

• Can’t compile.

• Can’t trust.

• Can’t predict.

• Can’t install or store.

• Can’t hide anything!

Page 70: Professional Frontend Engineering

Douglas Crockford on browsers:

“The most hostile software development

environment imaginable.”

Page 71: Professional Frontend Engineering

If your business is online...your value depends on Frontend Engineering.

Page 72: Professional Frontend Engineering

Elegant algorithms benefit users through interfaces built by

Frontend Engineers.

Page 73: Professional Frontend Engineering

Every gorgeous design is brought to life by Frontend

Engineers.

Page 74: Professional Frontend Engineering

Frontend engineers give sites strength & resilience,

appearance & form, and functionality & interactivity.

Page 75: Professional Frontend Engineering

...which is why professional frontend engineering is critical for success.

Page 76: Professional Frontend Engineering

Historical Perspective

Our Beliefs& Principles

Page 77: Professional Frontend Engineering

Four Guiding Principles

Page 78: Professional Frontend Engineering

1) Availability

Page 79: Professional Frontend Engineering

Availability:Maximize availability, accessibility and utility of content and services for all users worldwide.

Page 80: Professional Frontend Engineering

2) Openness

Page 81: Professional Frontend Engineering

Openness:Share. Learn. Support. Advocate.We benefit from a healthy Internet.

Page 82: Professional Frontend Engineering

3) Richness

Page 83: Professional Frontend Engineering

Richness:Provide, but not too much.Layer endlessly.Remember we are not average.

Page 84: Professional Frontend Engineering

4) Stability

Page 85: Professional Frontend Engineering

Stability:The Web is young. Invest in quality. Prepare for the future.

Page 86: Professional Frontend Engineering

Four Guiding Principles

• Availability

• Openness

• Richness

• Stability

Page 87: Professional Frontend Engineering

Three Core Techniques

Page 88: Professional Frontend Engineering

1) Graded Browser Support

http://developer.yahoo.com/yui/articles/gbs/

Page 89: Professional Frontend Engineering

“Support” does not mean identical.

Page 90: Professional Frontend Engineering

“Support” is not a binary choice.

Page 91: Professional Frontend Engineering

Three Support Grades

Page 92: Professional Frontend Engineering

Three Support GradesC-Grade

• Blacklist (of incapable browsers)

• Withhold CSS & JavaScript

Page 93: Professional Frontend Engineering

Three Support GradesC-Grade

• Blacklist (of incapable browsers)

• Withhold CSS & JavaScript

A-Grade

• Whitelist (of capable browsers tested)

• Serve CSS & JavaScript

Page 94: Professional Frontend Engineering

Three Support GradesC-Grade

• Blacklist (of incapable browsers)

• Withhold CSS & JavaScript

A-Grade

• Whitelist (of capable browsers tested)

• Serve CSS & JavaScript

X-Grade

• Everybody else.

• Serve CSS & JavaScript

Page 95: Professional Frontend Engineering

A-Grade Supporthttp://developer.yahoo.com/yui/articles/gbs

Page 96: Professional Frontend Engineering

C-Grade Experience

Page 97: Professional Frontend Engineering

A-Grade Experience

Page 98: Professional Frontend Engineering

C-Grade Experience

Page 99: Professional Frontend Engineering

A-Grade Experience

Page 100: Professional Frontend Engineering

2) Progressive Enhancement

Page 101: Professional Frontend Engineering

Rules of Progressive Enhancement

Page 102: Professional Frontend Engineering

Rules of Progressive Enhancement

• Enrich content with thorough, explicit markup.

Page 103: Professional Frontend Engineering

Rules of Progressive Enhancement

• Enrich content with thorough, explicit markup.

• Test core functionality with HTML only.

Page 104: Professional Frontend Engineering

Rules of Progressive Enhancement

• Enrich content with thorough, explicit markup.

• Test core functionality with HTML only.

• Enhance layout via externally linked CSS.

Page 105: Professional Frontend Engineering

Rules of Progressive Enhancement

• Enrich content with thorough, explicit markup.

• Test core functionality with HTML only.

• Enhance layout via externally linked CSS.

• Enhance behavior via externally linked unobtrusive JavaScript.

Page 106: Professional Frontend Engineering

Rules of Progressive Enhancement

• Enrich content with thorough, explicit markup.

• Test core functionality with HTML only.

• Enhance layout via externally linked CSS.

• Enhance behavior via externally linked unobtrusive JavaScript.

• Respect end-user browser preferences.

Page 107: Professional Frontend Engineering

Flipped definition of “graceful degradation”

Page 108: Professional Frontend Engineering

3) Unobtrusive JavaScripthttp://onlinetools.org/articles/unobtrusivejavascript/

Page 109: Professional Frontend Engineering

Rules of Unobtrusive JavaScript

Page 110: Professional Frontend Engineering

Rules of Unobtrusive JavaScript

• No JavaScript in HTML documents.

Page 111: Professional Frontend Engineering

Rules of Unobtrusive JavaScript

• No JavaScript in HTML documents.

• Don’t depend on or trust JavaScript.

Page 112: Professional Frontend Engineering

Rules of Unobtrusive JavaScript

• No JavaScript in HTML documents.

• Don’t depend on or trust JavaScript.

• Poke objects before using them.

Page 113: Professional Frontend Engineering

Rules of Unobtrusive JavaScript

• No JavaScript in HTML documents.

• Don’t depend on or trust JavaScript.

• Poke objects before using them.

• Write JavaScript, not dialects.

Page 114: Professional Frontend Engineering

Rules of Unobtrusive JavaScript

• No JavaScript in HTML documents.

• Don’t depend on or trust JavaScript.

• Poke objects before using them.

• Write JavaScript, not dialects.

• Mind your manners with vars & scope.

Page 115: Professional Frontend Engineering

Rules of Unobtrusive JavaScript

• No JavaScript in HTML documents.

• Don’t depend on or trust JavaScript.

• Poke objects before using them.

• Write JavaScript, not dialects.

• Mind your manners with vars & scope.

• Support multiple event triggers.

Page 116: Professional Frontend Engineering

Don’t Break the Web!

href=“#”

href=“javascript:foo()”

onclick=“foo()”

Page 117: Professional Frontend Engineering

Three Core Techniques

• Graded Browser Support

• Progressive Enhancement

• Unobtrusive JavaScript

Page 118: Professional Frontend Engineering

Making Decisions

Page 119: Professional Frontend Engineering

Making Decisions (1)

1. Do what is standard.

if impossible, then:

2. Do what is common.

if impossible, then:

3. Do what it takes.

Page 120: Professional Frontend Engineering

Making Decisions (2)

1. Do what is simple.

2. Do what is flexible & progressive.

3. Do what is open.

Page 121: Professional Frontend Engineering

Making Decisions (3)

• Remember you have multiples audiences to satisfy:

• Users

• Developers

• Machines

Page 122: Professional Frontend Engineering

Historical Perspective

Our Beliefs& Principles

Knowledge Areas & Best

Practices

Page 123: Professional Frontend Engineering

8 Areas of Focus1. HTML

2. CSS

3. JavaScript

4. Accessibility

5. Internationalization

6. Performance

7. Infrastructure & Process

8. Tooling

Page 124: Professional Frontend Engineering

HTML

Focus

#1

Page 125: Professional Frontend Engineering

Focus: Be thorough.

Page 126: Professional Frontend Engineering

<label>

Page 127: Professional Frontend Engineering

<fieldset>

Page 128: Professional Frontend Engineering

<cite>

Page 129: Professional Frontend Engineering

<caption>

Page 130: Professional Frontend Engineering

<thead>

Page 131: Professional Frontend Engineering

<th scope=”row” abbr=”ManU”>

Page 132: Professional Frontend Engineering

<ins datetime=”2008-05-30”>

Page 133: Professional Frontend Engineering

Aim for permanence.

Page 134: Professional Frontend Engineering

Switching costsare rising.

Page 135: Professional Frontend Engineering

CSS

Focus

#2

Page 136: Professional Frontend Engineering

Focus on the left side.

Page 137: Professional Frontend Engineering

selector: declaration;

Page 138: Professional Frontend Engineering

selector: declaration;

Page 139: Professional Frontend Engineering

Focus: Specificitygreat selectors are an

expression of professionalism

Page 140: Professional Frontend Engineering

h1: declaration;

Page 141: Professional Frontend Engineering

#mod h1: declaration;

Page 142: Professional Frontend Engineering

div#mod h1: declaration;

Page 143: Professional Frontend Engineering

body.cart #mod h1.class a: declaration;

Page 144: Professional Frontend Engineering

#mod ul li li: declaration;

Page 145: Professional Frontend Engineering

Focus: Maintenancethink about how sites age

Page 146: Professional Frontend Engineering

JavaScript

Focus

#3

Page 147: Professional Frontend Engineering

JavaScript

• Quality

• Security

Page 148: Professional Frontend Engineering

1) Quality

Page 149: Professional Frontend Engineering

Linting

• Use programs like JSLint (jslint.org) to confirm the quality of your code.

• Adopt the idioms it promotes to improve your code quality.

Page 150: Professional Frontend Engineering

Unit Testing w/ YUI Test

• Rapid creation of test cases via simple syntax.

• Advanced failure detection for methods that throw errors.

• Grouping of related test cases using test suites.

• Asynchronous tests for testing events and Ajax communication.

• DOM Event simulation in all A-grade browsers.

Page 151: Professional Frontend Engineering

Profiling

• Learn where to improve your code.

• Programmatically retrieve profiling information as the application is running.

• Determine unit-testing success based on profiling results.

Page 152: Professional Frontend Engineering

JavaScript Pollution

• Do not mutate JavaScript itself.

• Do protect yourself from browsers.

• Minimize touchpoints between authors and vendors so vendors can iterate faster.

Page 153: Professional Frontend Engineering

2) Security

Page 154: Professional Frontend Engineering

JavaScript Security

• Beware of XSS

• Never Trust Data from the Client

• Monitor AdSafe/Caja Developments

Page 155: Professional Frontend Engineering

Accessibility

Focus

#4

Page 156: Professional Frontend Engineering

ARIA

Page 157: Professional Frontend Engineering

Decoupled Events

Page 158: Professional Frontend Engineering

Internationalization

Focus

#5

Page 159: Professional Frontend Engineering

Begin serving all .css and .js at UTF-8

Page 160: Professional Frontend Engineering

@charset "

Page 161: Professional Frontend Engineering

Performance

Focus

#6

Page 162: Professional Frontend Engineering

14 then. 8 more today.

Page 163: Professional Frontend Engineering

<link> not @import

• Because @import overrides the browsers’ native performance sequencing.

Page 164: Professional Frontend Engineering

Avoid Redirects

• 3xx status codes – mostly 301 and 302HTTP/1.1 301 Moved Permanently Location: http://yahoo.com/newuri

• Cache redirects via Expires headers

• Redirects are worstform of blocking

Page 165: Professional Frontend Engineering

Use Cookie-Free Domains For Assets.

• Serving static cacheable assets from a distinct domains keeps cookies from riding along with all requests.yimg.comimages-amazon.comfbcdn.net

Page 166: Professional Frontend Engineering

Preload Assets

Page 167: Professional Frontend Engineering

Preload Assets

1. Unconditional preload - always w/ onloadExample: google.com’s sprite

Page 168: Professional Frontend Engineering

Preload Assets

1. Unconditional preload - always w/ onloadExample: google.com’s sprite

2. Conditional preload - based on user actionEx: search.yahoo.com’s Search Assist

Page 169: Professional Frontend Engineering

Preload Assets

1. Unconditional preload - always w/ onloadExample: google.com’s sprite

2. Conditional preload - based on user actionEx: search.yahoo.com’s Search Assist

3. Anticipated preload - give redesigns a boost

Page 170: Professional Frontend Engineering

Optimize CSS Sprites

Page 171: Professional Frontend Engineering

Optimize CSS Sprites

1. Horizontal alignment is usually smaller than vertical.

Page 172: Professional Frontend Engineering

Optimize CSS Sprites

1. Horizontal alignment is usually smaller than vertical.

2. Combine similar colors in a sprite to minimize color count.Only 256 colors can fit in a PNG8.

Page 173: Professional Frontend Engineering

Optimize CSS Sprites

1. Horizontal alignment is usually smaller than vertical.

2. Combine similar colors in a sprite to minimize color count.Only 256 colors can fit in a PNG8.

3. Avoid unnecessarily large gaps between parts of the sprite.

Page 174: Professional Frontend Engineering

GET for Ajax Requests

• POST is a two-step process.

• GET can send in one packet.

• Use if possible, but max payload is 2K in IE.

Page 175: Professional Frontend Engineering

Keep Focusing on Events

1. Event Delegation to reduce total number

2. Don’t always wait for onLoad

• YUI Event has onAvailable, onContentReady, & onDomReady

Page 176: Professional Frontend Engineering

iPhone Tip

• iPhone will not cache assets larger than 25K

• That’s 25K uncompressed.

• Only 19 total items in cache.

• http://yuiblog.com/blog/2008/02/06/iphone-cacheability/

Page 177: Professional Frontend Engineering

Infrastructure & Process

Focus

#7

Page 178: Professional Frontend Engineering

Build Process

Page 179: Professional Frontend Engineering

Documentation

Page 180: Professional Frontend Engineering

three versions of each member

Page 181: Professional Frontend Engineering

*.js

Page 182: Professional Frontend Engineering

*-debug.js

Page 183: Professional Frontend Engineering

*-min.js

Page 184: Professional Frontend Engineering

What Is YUI?

Page 185: Professional Frontend Engineering

Tooling

Focus

#8

Page 186: Professional Frontend Engineering

Need More Progress.

Page 187: Professional Frontend Engineering

But there’s been some:

• JSLint, JScript Debugger, Firebug, Debug Bar, Fiddler, Charles, HTTP Live Headers, DragonFly, Visual Studio 2008

• YUI Logger, YUI Test, and YUI Profiler

Page 188: Professional Frontend Engineering

Historical Perspective

Why It All Matters

Our Beliefs& Principles

Knowledge Areas & Best

Practices

Page 189: Professional Frontend Engineering

There’s a lot ofwork to be done.

Page 190: Professional Frontend Engineering

We need morepeople doing it.

Page 191: Professional Frontend Engineering

The health of the internet depends on it.

Page 192: Professional Frontend Engineering

The health of our businesses and passions

depends on it.

Page 193: Professional Frontend Engineering

We must stay vigilant.

Page 194: Professional Frontend Engineering

We must defend users.

Page 195: Professional Frontend Engineering

Go forth with this in mind:

Page 196: Professional Frontend Engineering

Be Tireless Trendsetters of Quality

Be active. Find the way forward.

Educate.

Page 197: Professional Frontend Engineering

Be Belligerent Gatekeepers of Quality

Do not accept less. Do not cut corners.

Page 198: Professional Frontend Engineering

Exhibit Stubborn Empathy for Users

We’re the last line of defense!

Page 199: Professional Frontend Engineering

Let’s keep talking...

[email protected] http://nate.koechley.com/blog “natekoechley”

Page 201: Professional Frontend Engineering

[email protected] http://nate.koechley.com/blog

natekoechley = twitter, delicious, flickr, tripit, last.fm, linkedin, fireeagle, friendfeed, ... everywhere.