a little journey into website optimization

83
Fast Fast ER Fast a little journey into Website Optimization EST

Upload: stelian-firez

Post on 08-May-2015

5.324 views

Category:

Technology


0 download

DESCRIPTION

Fast, Faster, Fastest - A little journey into website optimization is a presentation given at Fronteers BE which covers the main techniques and tools that can help you achieve the best performance for your website. From various ways to compress images, to writing very efficient CSS, to using cache and compression to your advantage, the slides will explain why front-end optimization is necessary, how it impacts a business and even how big companies use performance perception for their websites.

TRANSCRIPT

Page 1: A little journey into website optimization

Fast FastER Fasta little journey into Website Optimization

EST

Page 2: A little journey into website optimization

@stelianweb designer @digitibelieves in optimization

Page 3: A little journey into website optimization

“People don’t like to wait”

- Captain Obvious

Page 4: A little journey into website optimization
Page 5: A little journey into website optimization

40% of people abandon a website that takes

more than 3 seconds

to load.

- Forrester Research

Page 6: A little journey into website optimization

online shoppers expect pages to load in

2 seconds

- Forrester Research

Page 7: A little journey into website optimization

on the web 250ms might

win you the race

- Google & Microsoft studies

Page 8: A little journey into website optimization

Page load times affect online businesses

Page 9: A little journey into website optimization
Page 10: A little journey into website optimization

+500ms

Page loadtime Tr

affic

-3%

Page 11: A little journey into website optimization

+500ms

Page loadtime

Reve

nue -1.2%

Page 12: A little journey into website optimization

+100ms

Page loadtime

-1%

Sale

s

Page 13: A little journey into website optimization

- Steve Saunders, Google

“80-90% of the end-user response time is spent on the

front-end”

Page 14: A little journey into website optimization

ObjectivesLow number of filesSmall file sizeFast rendering

Page 15: A little journey into website optimization

Low number of files

Page 16: A little journey into website optimization

"Every HTTP request is a gamble. A chance to

fail."

- Scott Jehl

Page 17: A little journey into website optimization

6Connections per Hostname

Page 18: A little journey into website optimization

Use CSS Sprites

Page 19: A little journey into website optimization
Page 20: A little journey into website optimization

1 CSS file

Page 21: A little journey into website optimization

1 CSS file, ideally

Page 22: A little journey into website optimization

29

Page 23: A little journey into website optimization
Page 24: A little journey into website optimization

Use @media printinstead of print.css

Page 25: A little journey into website optimization

1 JS file per hostname

Page 26: A little journey into website optimization

40+

Page 27: A little journey into website optimization
Page 28: A little journey into website optimization

Small file size

Page 29: A little journey into website optimization

Writesemantic HTML

avoiding unnecessary elements

Page 30: A little journey into website optimization

Minify thejavascript

Page 31: A little journey into website optimization

Smaller CSSuse a reset.css file to avoid repetitionuse shorthand properties*design with consistencyremove unused styling

* for the designers

Page 32: A little journey into website optimization

Normalbody{    font-family: "Lucida Grande", Lucida, Verdana, sans-serif;    font-size: 1em;    line-height: 1.5em;    font-style: italic;    font-weight: bold;}

Shorthandbody{    font: italic bold 1em/1.5em "Lucida Grande", Lucida, Verdana, sans-serif;}

Page 33: A little journey into website optimization

Consistency: font-size

Alexa top 1000 websites

78%10+

23%100+

The number of font-size declarations

Page 34: A little journey into website optimization

Consistency: patterns

source: stubbornella.org

Page 35: A little journey into website optimization

Minify theCSS

Page 36: A little journey into website optimization

Use font subsetsif possible

Page 37: A little journey into website optimization

Choose theright image format

84%binary files (images,

PDFs, ...)

Alexa top 1000 websites

Page 38: A little journey into website optimization

GIFOnly for animations

Page 39: A little journey into website optimization

PNG-8for small dimensions and no need for

true color support; recommended for illustrations

Page 40: A little journey into website optimization

PNG-8 Alpha TransparencyFireworks

Page 41: A little journey into website optimization

PNG-8 Alpha TransparencyImageAlpha (Free)

Page 42: A little journey into website optimization

PNG-24when in need for high quality

graphics, although it tends to get bigger in size

Page 43: A little journey into website optimization

Use posterization to reduce the number of

colors in a PNG-24 file

Page 44: A little journey into website optimization

JPEGgreat for large images that contain

photographic data

Page 45: A little journey into website optimization

JPEG tips80% quality is usually good enoughtry to align edges to an 8x8 pixel griduse JPEG selective quality in FW

Page 46: A little journey into website optimization

JPEGLeft square aligned to the 8x8 grid,

right one not

Page 47: A little journey into website optimization

JPEG Selective Qualityin Fireworks

Page 48: A little journey into website optimization

Use ImageOptimto compress images further

Alternatives: smush.it, punypng, jpegmini

Page 49: A little journey into website optimization
Page 50: A little journey into website optimization
Page 51: A little journey into website optimization

Original PNG-8 + Alpha Transparency

1068 KB 263 KB

Page 52: A little journey into website optimization

Original PNG-8 + Alpha +ImageOptim

1068 KB 228 KB

Page 53: A little journey into website optimization

Fast rendering

Page 54: A little journey into website optimization

Cache static files

Page 55: A little journey into website optimization

Cache static filesforever

Page 56: A little journey into website optimization

“e fastest HTTP request is the one not

made”

Page 57: A little journey into website optimization

Using .htaccessHeader unset PragmaFileETag NoneHeader unset ETag # cache images for 10 years<FilesMatch "\.(ico|pdf|jpg|jpeg|png|gif)$"> Header set Cache-Control "max-age=315360000, public, must-revalidate" Header unset Last-Modified</FilesMatch> # cache html/htm/xml/txt files for 2 hours<FilesMatch "\.(html|htm|xml|txt|xsl)$"> Header set Cache-Control "max-age=7200, must-revalidate"</FilesMatch>

this is just an example;for best results, use HTML5 Boilerplate

Page 58: A little journey into website optimization

Cache AJAX requests

Page 59: A little journey into website optimization

Faster CSS

Don't use @importStay away from *Avoid using a tag as a key

body * {...}body > * {...}ul.active li a {...}ul.active > li > a {...}

Page 60: A little journey into website optimization

Use CSS3 responsiblydon’t overuse border-radius, box-shadow,

gradients

http://perfectionkills.com

Page 61: A little journey into website optimization

Use domain shardingto increase the number of

concurrent connections

Page 62: A little journey into website optimization

Use a CDNContent Delivery Network

Page 63: A little journey into website optimization

Use CDN hostedJS libraries

Page 64: A little journey into website optimization

Specify the jQuery versionfor better caching

http://code.jquery.com/jquery-latest.min.js

http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js

http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js

no cache

1 hour

1 year

Page 65: A little journey into website optimization

Always load scriptsasyncroniusly and put them at the bottom of

the page

Page 66: A little journey into website optimization

Compress only compressible resources

HTML, CSS, JS, XML, SVG, ICOuse GZIP instead of Deflateuse lowercase for better compressionHTML5 Boilerplate .htaccess recommened

Page 67: A little journey into website optimization

e faviconhave one to avoid a 404load it from a subdomaincompress itcache it forever

Page 68: A little journey into website optimization

Avoid mixed content warnings

http://code.jquery.com/jquery-latest.min.js

//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js

Page 69: A little journey into website optimization

Minimize reflows

Page 70: A little journey into website optimization

Watch out for 404faviconapple touch iconsapple-touch-icon-ZxZ-precomposed (android)

crossdomain.xml

Page 71: A little journey into website optimization

Trigger hardware accelerated CSS in iOS

Page 72: A little journey into website optimization

TestPageSpeed, Yslow

Page 73: A little journey into website optimization

MeasureGoogle Analytics Site

Speed

//default sample rate is 1%_gaq.push(['_setSiteSpeedSampleRate', 5]);

Page 74: A little journey into website optimization

So, what now?

Page 75: A little journey into website optimization

Cheat Lie

Deceive

Page 76: A little journey into website optimization

Performance Perception

Page 77: A little journey into website optimization

AppleThe iPhone saves a screenshot of every app

when it closes. So when you relaunch the app it loads that screenshot first.

Page 78: A little journey into website optimization

Instagram

Page 79: A little journey into website optimization

Instagram

Page 80: A little journey into website optimization

Instagram

Page 81: A little journey into website optimization

Amazon

Priority Loading

Page 82: A little journey into website optimization

Tools & Resources(1 of 2)Tools๏ ImageOptim

๏ ImageAlpha

๏ HTML5 Boilerplate

๏ Smush.it - PunyPNG - JPEGmini - PNGGauntlet (Win)

๏ Online YUI Compressor

๏ CSS Sprite Generator - CSSsprite Photoshop script

๏ Page Speed - YSlow

Resources๏ Akamai Reveals 2 Seconds as the New Threshold of Acceptability for eCommerce Web Page Response Times

๏ How Loading Time Affects Your Bottom Line (Infographic)

๏ For Impatient Web Users, an Eye Blink Is Just Too Long to Wait

๏ Facebook pages that are 500ms slower result in a 3% drop-off in traffic (PDF)

๏ If Google increased page load by 500ms it would cost them 1.2% of their revenue (Video)

๏ Every 100ms of latency costs Amazon 1% of profit

๏ The Performance Golden Rule

Page 83: A little journey into website optimization

Tools & Resources(2 of 2)๏ Most Browsers Allow 6 Concurrent Connections per Hostname

๏ Top 5 Mistakes of Massive CSS (Video + Graphs)

๏ How to create CSS objects? Get the granularity right!

๏ HTTP Compression use by Alexa Top 1000

๏ Profiling CSS for fun and profit. Optimization notes. (CSS3 Performance)

๏ Maximize Your Chances of Caching Your jQuery

๏ Lose the Wait: HTTP Compression

๏ Instagram and Optimizing Favicons

๏ Use Lowercase Markup For Better Compression

๏ Small site? Raise your page load time calculation sample to 100%

๏ The iPhone’s Perceived Performance

๏ The 3 White Lies Behind Instagram’s Lightning Speed

๏ Making a Slow Site Appear Fast