Title: Steve Souders
1High Performance Web SitesEssential Knowledge
for Frontend Engineers
- Steve Souders
- souders_at_google.com
- http//stevesouders.com/
Disclaimer This content does not necessarily
reflect the opinions of my employer.
2The Importance of Frontend Performance
9
91
17
83
iGoogle, primed cache
iGoogle, empty cache
3Time Spent on the Frontend
Empty Cache Primed Cache
www.aol.com 97 97
www.ebay.com 95 81
www.facebook.com 95 81
www.google.com/search 47 25
search.live.com/results 67 0
www.msn.com 98 94
www.myspace.com 98 98
en.wikipedia.org/wiki 94 91
www.yahoo.com 97 96
www.youtube.com 98 97
4The Performance Golden Rule
80-90 of the end-user response time is spent on
the frontend. Start there.
greater potential for improvement
simpler
proven to work
514 Rules
- Make fewer HTTP requests
- Use a CDN
- Add an Expires header
- Gzip components
- Put stylesheets at the top
- Put scripts at the bottom
- Avoid CSS expressions
- Make JS and CSS external
- Reduce DNS lookups
- Minify JS
- Avoid redirects
- Remove duplicate scripts
- Configure ETags
- Make AJAX cacheable
6YSlow
High Performance Web Sites
7- http//conferences.oreilly.com/velocity/ 20
discount vel08st
8Rule 1 Make fewer HTTP requests
- CSS sprites
- combined scripts, combined stylesheets
- image maps
- inline images
9CSS Sprites
ltspan style" background-image
url('sprites.gif') background-position -260px
-90px"gt lt/spangt
- size of combined image is less
10Rule 3 Add an Expires header
Images Stylesheets Scripts with Expires Median Age
amazon.com 0/62 0/1 0/3 0 114 days
aol.com 23/43 1/1 6/18 48 217 days
cnn.com 0/138 0/2 2/11 1 227 days
ebay.com 16/20 0/2 0/7 55 140 days
google.com/ig 8/14 1/1 2/3 65 8 days
msn.com 32/35 1/1 3/9 80 34 days
myspace.com 0/18 0/2 0/2 0 1 day
wikipedia.org 6/8 1/1 2/3 75 1 day
yahoo.com 23/23 1/1 4/4 100 n/a
youtube.com 0/32 0/3 0/7 0 26 days
11Rule 5 Put stylesheets at the top
- stylesheets block rendering in IE
- solution put stylesheets in HEAD (per spec)
- avoids Flash of Unstyled Content
- use LINK (not _at_import)
12Rule 6 Move scripts to the bottom
- scripts block parallel downloads across all
hostnames - scripts block rendering of everything below them
in the page - move scripts as low in the page as possible
13Even Faster Web Sites
- Split the initial payload
- Load scripts without blocking
- Don't scatter scripts
- Split dominant content domains
- Make static content cookie-free
- Reduce cookie weight
- Minify CSS
- Optimize images
- Use iframes sparingly
- To www or not to www
14Why focus on JavaScript?
15 16Takeaways
- focus on the frontend
- run YSlow http//developer.yahoo.com/yslow
- Velocity http//conferences.oreilly.com/velocity/
- speed matters
- you CAN make your site even faster!
17Steve Souders souders_at_google.com http//stevesoude
rs.com/