responsive web design from the future

89
WEB DESIGN FROM THE FUTURE RESPONSIVE pushState. replaceState. Hashbangs!# AJAX. PJAX. Beets. Bears. Battlestar Galactica.

Upload: new-tech

Post on 22-May-2015

556 views

Category:

Technology


4 download

DESCRIPTION

Industry recommended best practices by Kyle Neath. Copyrights reserved by the author. Shared under Fair Use policy. Original source: http://warpspire.com/talks/responsive/

TRANSCRIPT

Page 1: Responsive web design from the future

WEB DESIGNFROM THE FUTURE

RESPONSIVE

pushState. replaceState. Hashbangs!# AJAX. PJAX. Beets. Bears. Battlestar Galactica.

Page 2: Responsive web design from the future

Kyle Neath is...

Page 3: Responsive web design from the future

~designer@

Page 4: Responsive web design from the future

@kneath

Page 5: Responsive web design from the future

warpspire.com

Page 6: Responsive web design from the future

URL DesignPartial Page Updates

Let’s talk about

Page 7: Responsive web design from the future

The future of the web is…

HTML5 History API+

Smart Partial Page Updates

Page 8: Responsive web design from the future

The future of the web is…

RESPONSIVE

Page 9: Responsive web design from the future

How do you define responsive?

Page 10: Responsive web design from the future

Resize the browser

With an iPad / Playbook

Responsive Web Design

(lol/jk)

“”

Page 11: Responsive web design from the future

Fast pageloads

Animates naturally

Responds instantly

Feels Faster™

click touch zoom scroll swipe type resize

Page 12: Responsive web design from the future

Keyboard Shortcuts

Back & Forward Buttons

URL Hacking

Browser Native

Page 13: Responsive web design from the future

Technologies

Page 14: Responsive web design from the future

@media queriesModernizr

jQuery.hotKeysCSS3 Animations

HTML5 History APIXMLHTTPRequestmustache.js

Page 15: Responsive web design from the future

@media queriesModernizr

jQuery.hotKeysCSS3 Animations

HTML5 History APIXMLHTTPRequestmustache.js

TOO MUCH FOR ONE DAY

Page 16: Responsive web design from the future

… and how GitHub is stumbling through them

Page 17: Responsive web design from the future

URL DesignMy recent love affair

Page 18: Responsive web design from the future

URLs are sexy

Page 19: Responsive web design from the future

Working with Terminal made me love URLs

Page 20: Responsive web design from the future
Page 21: Responsive web design from the future

Who needs directions if you can skip to the destination?

URLs are like transporters

Page 22: Responsive web design from the future

Everything should have a URL

Page 23: Responsive web design from the future
Page 24: Responsive web design from the future

A URL is an agreement

Page 25: Responsive web design from the future

Can you see a future with hashbangs?

#!/defunct

Page 26: Responsive web design from the future

// Redirect legacy anchor-based issue urls to real URLs.var location_with_hash = location.pathname + location.hashvar matches = location_with_hash.match(/#issue\/(\d+)(\/comment\/(\d+))?/)if (matches) {  var issue_number = matches[1]  var comment_id = matches[3]  if (issue_number) {    if (comment_id) {      window.location = location_with_hash.replace(/\/?#issue\/\d+\/comment\/\d+/, "/"+issue_number+"#comment_"+comment_id)    } else {      window.location = location_with_hash.replace(/\/?#issue\/\d+/, "/" + issue_number)    }  }}

FOREVER

Page 27: Responsive web design from the future

An <a> should behave like an <a>

Page 28: Responsive web design from the future

⌘ + click⇧ + click

Middle click

Page 29: Responsive web design from the future
Page 30: Responsive web design from the future

Be responsive!Browsers have

windows & tabs

Page 31: Responsive web design from the future

e.which == 1&&

!e.metaKey&&

!e.shiftKey

Page 32: Responsive web design from the future

Feels Faster™Making people say

Page 33: Responsive web design from the future

Welcome to the AJAX Generation

Page 34: Responsive web design from the future
Page 35: Responsive web design from the future

Welcome to the AJAX GenerationiPhone Generation

Page 36: Responsive web design from the future
Page 37: Responsive web design from the future

Fast is about perception

Page 38: Responsive web design from the future
Page 39: Responsive web design from the future

= 1 billion SQL Queries

2 billion Memcache calls3 billion Git calls

Page 40: Responsive web design from the future

SLOW

Page 41: Responsive web design from the future

Why are we focusing up here?

This is the part that changes

Page 42: Responsive web design from the future

Caching!…is really difficult

Page 43: Responsive web design from the future

AJAX!

Page 44: Responsive web design from the future

AJAX!loaders are not responsive

Page 45: Responsive web design from the future
Page 46: Responsive web design from the future
Page 47: Responsive web design from the future

Only use loaders when requests are slow

~500ms

Cache content forzero-request updates

Think about the back button

Page 48: Responsive web design from the future

There will always be full page loads

Page 49: Responsive web design from the future

Serve all HTML (or JSON) in one request

If you want fast…

Page 50: Responsive web design from the future
Page 51: Responsive web design from the future

Remember, page load time is about perception

When can I: scroll, read text, click links?

Page 52: Responsive web design from the future

Twitter: HTML + CSS + JS

API Driven

Page 53: Responsive web design from the future

Apply Sciencehttps://twitter.com/#!/kneath

4.7sec total load time

4.3sec timeline load

Time to usable!

Page 54: Responsive web design from the future

Apply Sciencehttps://github.com/kneath

3.4sec total load time

1.1sec HTML/CSS/JS loaded

Time to usable!

Page 55: Responsive web design from the future

Why is Twitter’s so slow?

Page 56: Responsive web design from the future

SSL

Page 57: Responsive web design from the future

Each domain is a new SSL Handshaketwitter.com

api.twitter.com

Page 58: Responsive web design from the future

Handshakes and Waterfalls

SSLtwitter.com

SSLapi.twitter.com

HTML, CSS, JS

JSON Data

Page 59: Responsive web design from the future

SSL Negotiation is our bottleneck

40ms backend response time500ms blocking SSL Negotiation

Page 60: Responsive web design from the future

Always favor science over theory

Page 61: Responsive web design from the future

Be Responsive

Client-Side Cache

AJAX/JSON Request

Full Page

Page 62: Responsive web design from the future
Page 63: Responsive web design from the future

Server or client side template rendering?

So if we want partial page updates sometimes, full page updates other times…

Page 64: Responsive web design from the future

Use the same templates

Both!

mustache.rb mustache.js

Render HTML in AJAX/JSONpartials are your friend

Page 65: Responsive web design from the future

With SSL negotiation, server time is ~free

One is simpler than two

But…

Page 66: Responsive web design from the future

URL Design+

Feels Faster™

Page 67: Responsive web design from the future
Page 68: Responsive web design from the future

HTML5 History APImakes me all tingly

Page 69: Responsive web design from the future

pushState

replaceState

URL Change + back button stack

URL Change only

Page 70: Responsive web design from the future

Partial page updates with real URLs!

Page 71: Responsive web design from the future

We can design for the back button!

Page 72: Responsive web design from the future

Browser Support?

5.0 4.0Yes

Page 73: Responsive web design from the future

Browser Support?

90%https://github.com

Page 74: Responsive web design from the future

history.jsbalupton/history.js

Page 75: Responsive web design from the future

Javascript redirects

If you use hashbangs…

two requests instead of one

Confusing code paths some routing in server, some in js?

Page 76: Responsive web design from the future

Some users get a slower experience

Cost of History API

But isn’t Chrome already faster than IE7?

Page 77: Responsive web design from the future

Poison your URL structure

Committing to nasty JS redirects FOREVER

Manual anchor Javascript

Cost of Hashbangs

Page 78: Responsive web design from the future

Futuristic designThis stuff is opening up

Page 79: Responsive web design from the future

State? We can do that

Page 80: Responsive web design from the future

?milestone=3&sort=created&direction=desc&state=open

Page 81: Responsive web design from the future

Save URLs in database

replaceState on loadbut only if there aren’t any params already

Page 82: Responsive web design from the future

Maintain state across pageviews

Copy & paste URLs over IM / chat

Page 83: Responsive web design from the future

Infinite Scroll? We can do that

(correctly)

Page 84: Responsive web design from the future

Facebook

Tumblr

Twitter

Lots of websites are using infinite scroll

Page 85: Responsive web design from the future

And they’re all broken

Page 86: Responsive web design from the future

Infinite scroll is only better than pages if you can restore your position

Page 88: Responsive web design from the future

Happy Unix Enthusiasts

Happy Grandmas

Happy Developers

Good URL Design + History APImakes for…

Page 89: Responsive web design from the future

warpspire.com/talks/responsive