Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

Kyle Neath is...

Slide 3

Slide 3 text

~designer @

Slide 4

Slide 4 text

@kneath

Slide 5

Slide 5 text

warpspire.com

Slide 6

Slide 6 text

URL Design Partial Page Updates Let’s talk about

Slide 7

Slide 7 text

The future of the web is… HTML5 History API + Smart Partial Page Updates

Slide 8

Slide 8 text

The future of the web is… RESPONSIVE

Slide 9

Slide 9 text

How do you define responsive?

Slide 10

Slide 10 text

Resize the browser With an iPad / Playbook Responsive Web Design (lol/jk) “ ”

Slide 11

Slide 11 text

Fast pageloads Animates naturally Responds instantly Feels Faster™ click touch zoom scroll swipe type resize

Slide 12

Slide 12 text

Keyboard Shortcuts Back & Forward Buttons URL Hacking Browser Native

Slide 13

Slide 13 text

Technologies

Slide 14

Slide 14 text

@media queries Modernizr jQuery.hotKeys CSS3 Animations HTML5 History API XMLHTTPRequest mustache.js

Slide 15

Slide 15 text

@media queries Modernizr jQuery.hotKeys CSS3 Animations HTML5 History API XMLHTTPRequest mustache.js TOO MUCH FOR ONE DAY

Slide 16

Slide 16 text

… and how GitHub is stumbling through them

Slide 17

Slide 17 text

URL Design My recent love affair

Slide 18

Slide 18 text

URLs are sexy

Slide 19

Slide 19 text

Working with Terminal made me love URLs

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

Who needs directions if you can skip to the destination? URLs are like transporters

Slide 22

Slide 22 text

Everything should have a URL

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

A URL is an agreement

Slide 25

Slide 25 text

Can you see a future with hashbangs? #!/defunct

Slide 26

Slide 26 text

// Redirect legacy anchor-based issue urls to real URLs. var location_with_hash = location.pathname + location.hash var 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+/ } else { window.location = location_with_hash.replace(/\/?#issue\/\d+/, "/" + issue_ } } } FOREVER

Slide 27

Slide 27 text

Slide 28

Slide 28 text

⌘ + click ⇧ + click Middle click

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

Be responsive! Browsers have windows & tabs

Slide 31

Slide 31 text

e.which == 1 && !e.metaKey && !e.shiftKey

Slide 32

Slide 32 text

Feels Faster™ Making people say

Slide 33

Slide 33 text

Welcome to the AJAX Generation

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

Welcome to the AJAX Generation iPhone Generation

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

Fast is about perception

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

= 1 billion SQL Queries 2 billion Memcache calls 3 billion Git calls

Slide 40

Slide 40 text

SLOW

Slide 41

Slide 41 text

Why are we focusing up here? This is the part that changes

Slide 42

Slide 42 text

Caching! …is really difficult

Slide 43

Slide 43 text

AJAX!

Slide 44

Slide 44 text

AJAX! loaders are not responsive

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

Only use loaders when requests are slow ~500ms Cache content for zero-request updates Think about the back button

Slide 48

Slide 48 text

There will always be full page loads

Slide 49

Slide 49 text

Serve all HTML (or JSON) in one request If you want fast…

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

Remember, page load time is about perception When can I: scroll, read text, click links?

Slide 52

Slide 52 text

Twitter: HTML + CSS + JS API Driven

Slide 53

Slide 53 text

Apply Science https://twitter.com/#!/kneath 4.7sec total load time 4.3sec timeline load Time to usable!

Slide 54

Slide 54 text

Apply Science https://github.com/kneath 3.4sec total load time 1.1sec HTML/CSS/JS loaded Time to usable!

Slide 55

Slide 55 text

Why is Twitter’s so slow?

Slide 56

Slide 56 text

SSL

Slide 57

Slide 57 text

Each domain is a new SSL Handshake twitter.com api.twitter.com

Slide 58

Slide 58 text

Handshakes and Waterfalls SSL twitter.com SSL api.twitter.com HTML, CSS, JS JSON Data

Slide 59

Slide 59 text

SSL Negotiation is our bottleneck 40ms backend response time 500ms blocking SSL Negotiation

Slide 60

Slide 60 text

Always favor science over theory

Slide 61

Slide 61 text

Be Responsive Client-Side Cache AJAX/JSON Request Full Page

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

Server or client side template rendering? So if we want partial page updates sometimes, full page updates other times…

Slide 64

Slide 64 text

Use the same templates Both! mustache.rb mustache.js Render HTML in AJAX/JSON partials are your friend

Slide 65

Slide 65 text

With SSL negotiation, server time is ~free One is simpler than two But…

Slide 66

Slide 66 text

URL Design + Feels Faster™

Slide 67

Slide 67 text

No content

Slide 68

Slide 68 text

HTML5 History API makes me all tingly

Slide 69

Slide 69 text

pushState replaceState URL Change + back button stack URL Change only

Slide 70

Slide 70 text

Partial page updates with real URLs!

Slide 71

Slide 71 text

We can design for the back button!

Slide 72

Slide 72 text

Browser Support? 5.0 4.0 Yes

Slide 73

Slide 73 text

Browser Support? 90% https://github.com

Slide 74

Slide 74 text

history.js balupton/history.js

Slide 75

Slide 75 text

Javascript redirects If you use hashbangs… two requests instead of one Confusing code paths some routing in server, some in js?

Slide 76

Slide 76 text

Some users get a slower experience Cost of History API But isn’t Chrome already faster than IE7?

Slide 77

Slide 77 text

Poison your URL structure Committing to nasty JS redirects FOREVER Manual anchor Javascript Cost of Hashbangs

Slide 78

Slide 78 text

Futuristic design This stuff is opening up

Slide 79

Slide 79 text

State? We can do that

Slide 80

Slide 80 text

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

Slide 81

Slide 81 text

Save URLs in database replaceState on load but only if there aren’t any params already

Slide 82

Slide 82 text

Maintain state across pageviews Copy & paste URLs over IM / chat

Slide 83

Slide 83 text

Infinite Scroll? We can do that (correctly)

Slide 84

Slide 84 text

Facebook Tumblr Twitter Lots of websites are using infinite scroll

Slide 85

Slide 85 text

And they’re all broken

Slide 86

Slide 86 text

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

Slide 87

Slide 87 text

http://warpspire.com/experiments/history-api

Slide 88

Slide 88 text

Happy Unix Enthusiasts Happy Grandmas Happy Developers Good URL Design + History API makes for…

Slide 89

Slide 89 text

warpspire.com/talks/responsive