98
Building Faster (& Beer) Sites Holger Bartel | @foobartel | FFCPH 8/11/2014

Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Embed Size (px)

DESCRIPTION

These are the slides from my talk at Form, Function, Class in Manila, Philippines on November 8th, 2014. Building better and faster websites is about why we need to better understand who for and how we are building sites and what approaches can help us to create faster and better overall experiences that will eventually result in happier users.

Citation preview

Page 1: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Building Faster (& Be!er) Sites

Holger Bartel | @foobartel | FFCPH 8/11/2014

Page 2: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Performance is a thing.

Page 3: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Nobody likes to wait. Also not for your site to load.

Slow is Bad!

Page 4: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Users expect sites to load in ~2-3 seconds…

Expectations

Page 5: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Users expect sites to load in ~2-3 seconds…

That’s the definition of ‘fast’

We’re even aiming to deliver something in even less

Expectations

Page 6: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

50% of people say they'll abandon a page that takes longer than 4 seconds to load

Expectations

Page 7: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Depending on location and what the user is used to this might be slightly longer

More than 6 seconds for sure is pushing it and people will leave

Expectations

Page 8: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Faster is Be!er!

Page 9: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Faster is Be!er! Why?

Page 10: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

The Real World (and why you should care)

Page 11: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

40% of surveyed online shoppers will abandon a page that takes more than 3

seconds to load.— Akamai (2009)

Page 12: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Speeding up a fundraising site by 60% increased donations by 14%.

— Kyle Rush, Obama Campaign (2012)

Page 13: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Adding half a second to a search results page can decrease traffic and ad

revenues by 20 percent — Google

Page 14: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Every additional 100 milliseconds of load time decreased sales by 1 percent.

— Amazon

Page 15: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Global Network Speed

Page 16: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

http://www.netindex.com

Global Broadband Download: 21.3Mbps

Global Mobile: Download: 10.9Mbps

Page 17: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Top 20 Countries Broadband Download 2012 - 2014

http://www.netindex.com

Page 18: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

PhilippinesDownload: 3.49Mbps (Mobile roughly the same)

IndonesiaDownload: 5.27Mbps (Mobile 2.67Mbps)

USADownload: 31.3Mbps (Mobile 13.33Mbps)

November 2014

http://www.netindex.com

Page 19: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Too good to be true…?

Page 20: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

3G, Edge, GPRS

http://en.wikipedia.org/wiki/Intercity-Express#mediaviewer/File:SiemensVelaroD-InnoTrans2010.jpg

Page 21: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

3G, Edge, GPRS, offline…

Page 22: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Faster is Be!er!

Page 23: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Progressive Enhancement

Page 24: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Because before thinking about making your site fast, we want to make sure it loads in the

first place.

Page 25: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

The idea of one web for everyone is one of our main goals.

We just have to figure out how to best do it, so eventually it will work well for everybody.

(Responsive) Web Design

Page 26: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

2012 - 2014

http://httparchive.org/interesting.php

Page 27: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Working with the unknowns

(Try to) Make the best assumptions

RWD Lessons

Page 28: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

We tried media queries & viewport sizes

But: You could be mobile on Wifi or with a laptop tethering EDGE in the jungle

How do we find out what our users want in their current environment?

Assumptions

Page 29: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Faster is Be!er!

Page 30: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Just like we did with pixel-perfect design, we have to let go of the idea of the same experience for all

browsers and all users.

Le!ing go…

Page 31: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Progressive Enhancement rather is about making core functionality available to everyone.

Everything on top of that is the ‘enhancement’ part.

…to progress

Page 32: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

http://en.wikipedia.org/wiki/Tightrope_walking

Every website is responsive from the start.

Everything else on top of it, is how we brake the base feature.

It’s easy!

Page 33: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014
Page 34: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014
Page 35: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

It’s all here already.

Page 36: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Start simple and look at the bigger picture.

Give users a great experience in its simplest form.

Then progressively enhance to deliver be"er experiences.

Page 37: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Performance is Design

Page 38: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Performance is Design

Design is Performance

Page 39: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Performance is Design

Design is Performance

Design directs Performance

Page 40: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

— Ian Feather

“Performance is a compromise between design and performance.

You can only be as fast as the design allows.”

Page 41: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Collaboration & communication between designers and developers nowadays is essential and more

important than ever before.

Breaking Silos

Page 42: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Get designs into the browser as soon as possible, so you, your team and your client can

get a be"er feel for what it will be like in the real world.

Page 43: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Ask yourself:

What's the gain?

What do you want to achieve?

Page 44: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

A carousel with 7 images - is it really worth the load time or just pre"y to look

at?

Page 45: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Whereas it's questionable if images 3-7 will be seen

in the first place.

Page 46: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

— Jake Archibald

“If images would be render blocking we'd probably think

twice about them.”

Page 47: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Performance Budgets

http://timkadlec.com/2013/01/setting-a-performance-budget/

Page 48: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Building for Performance

Page 49: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Rendering Pages

Page 50: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Waiting for DOM and CSSOM to build the render tree.

Render tree contains nodes to render the page.

Layout computes the exact position and size.

Paint turns the render tree into pixels on screen.

Render-Tree Construction, Layout & Paint

Page 51: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Waiting for CSS

Avoids “Flash of Unstyled Content” (FOUC)

Render Blocking CSS

Page 52: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

The parser has to stop for scripts before continuing to parse HTML.

JavaScript can query and modify DOM and CSSOM.

JavaScript blocks DOM construction unless explicitly declared as async.

Render Blocking JavaScript

Page 53: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Every request fetched inside of HEAD, will postpone the rendering of the page

Loading JavaScript

Page 54: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Every request takes roughly ~200ms

Avoid unnecessary redirects

Limit HTTP Requests

Page 55: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Critical Resource

Critical Path Length

Critical Bytes

Critical Rendering Path

Page 56: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Optimizing the dependency graph between HTML, CSS, and JavaScript.

Optimising the Critical Rendering

Path

https://developers.google.com/web/fundamentals/

Page 57: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Optimising the Critical Rendering

Path

=Ge!ing stuff on the

screen fast

Page 58: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

domLoading: this is the starting timestamp of the entire process - start parsing the first received bytes of the HTML

document

domContentLoaded: marks the point when both the DOM is ready and there are no stylesheets that are blocking

JavaScript execution

loadEvent: as a final step in every page load the browser fires an “onload” event

Navigation Timing API

Page 59: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Without CSS & JS

https://developers.google.com/web/fundamentals/

Page 60: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

With CSS & JS

https://developers.google.com/web/fundamentals/

Page 61: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

To get stuff on the screen fast…

Page 62: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Minimize the number of critical resources.

Minimize the number of critical bytes.

Minimize the critical path length.

A critical resource is a resource that can block initial rendering of a page.

Page 63: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Analyze and characterize: number of resources, bytes, length.

Minimize number of critical resources.

Optimize order of remaining critical resources being loaded: download critical assets as

early as possible.

Optimize the number of critical bytes to reduce the download time (number of

roundtrips).

Page 64: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014
Page 65: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014
Page 66: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014
Page 67: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014
Page 68: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014
Page 69: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014
Page 70: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Put your JavaScript files at the bo"om Optimize your images

Concatenate files Minimize files

Far future expires headers for caching

Google Page Speed YSlow

The low hanging fruit

Page 71: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Fastclick

Polyfill to remove click delays on browsers with touch UIs

Perceived Performance

Page 72: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Taming Framework Overhead

Page 73: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Frameworks

B

Page 74: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

It’s so easy to choose a framework like Bootstrap & plug in a li"le jQuery…

Kill The Lazy Developer In You

Page 75: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Do you really need all that stuff?

No?

Do something about it then!

Don’t trade Performance for a Framework

Page 76: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

CSS Spring CleaningCSS SPRING CLEANING

Page 77: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Just Like With Other Stuff

Page 78: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Too Much Overhead: 15.689 CSS rules

Page 79: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Built with Foundation 5 as an MVP Uses jQuery, jQuery UI, Vanilla JS

& various Grunt tasks

Missedin-HKG.com

Page 80: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014
Page 81: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014
Page 82: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

CSS File Size: 88Kb JS File Size: 213Kb

Development

CSS File Size: 3.8Kb JS File Size: 54.3Kb

Production

Page 83: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Tools

Page 84: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Standards for developing flexible, durable, and sustainable HTML and CSS.

Code Guide

http://mdo.github.io/code-guide/

Page 85: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

VirtualBox

Modern.ie

Browserstack.com

Sauce Labs

Cross-Browser Testing

Page 86: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Adobe Edge Inspect

Ghostlab

BrowserSync!

Device Testing

Page 87: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

6 Weeks

428 Different Devices

=

Page 88: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

http://opensignal.com/reports/2014/android-fragmentation/

Page 89: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Testing on Real Devices

opendevicelab.com

Photo: @viljamis http://devicelab.fi

Page 90: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Performance Testing

http://www.webpagetest.org

Page 91: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

http://tools.pingdom.com/fpt/

https://developers.google.com/speed/pagespeed/

https://developer.yahoo.com/yslow/

Performance Testing

Page 92: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Chrome Dev Tools

Page 93: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Perf-Tooling Today

http://perf-tooling.today

Page 94: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

With achieving fast page load time, people can quickly use your site and

accomplish what they want.

Page 95: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

People will appreciate it and end up being happier users.

Page 96: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Happier users mean be!er conversion rates.

Be!er conversion rates can be increased revenue, more signups,

returning visits, or downloads.

Page 97: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Faster is Be!er!So…

Page 98: Building Faster and Better Sites – Form, Function, Class Conference, Manila, Nov 8, 2014

Thanks!

Holger Bartel | @foobartel | FFCPH 8/11/2014