O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

High Performance Web Sites

Book Description

Want your web site to display more quickly? This book presents 14 specific rules that will cut 25% to 50% off response time when users request a page. Author Steve Souders, in his job as Chief Performance Yahoo!, collected these best practices while optimizing some of the most-visited pages on the Web. Even sites that had already been highly optimized, such as Yahoo! Search and the Yahoo! Front Page, were able to benefit from these surprisingly simple performance guidelines.

The rules in High Performance Web Sites explain how you can optimize the performance of the Ajax, CSS, JavaScript, Flash, and images that you've already built into your site -- adjustments that are critical for any rich web application. Other sources of information pay a lot of attention to tuning web servers, databases, and hardware, but the bulk of display time is taken up on the browser side and by the communication between server and browser. High Performance Web Sites covers every aspect of that process.

Each performance rule is supported by specific examples, and code snippets are available on the book's companion web site. The rules include how to:

  • Make Fewer HTTP Requests
  • Use a Content Delivery Network
  • Add an Expires Header
  • Gzip Components
  • Put Stylesheets at the Top
  • Put Scripts at the Bottom
  • Avoid CSS Expressions
  • Make JavaScript and CSS External
  • Reduce DNS Lookups
  • Minify JavaScript
  • Avoid Redirects
  • Remove Duplicates Scripts
  • Configure ETags
  • Make Ajax Cacheable

If you're building pages for high traffic destinations and want to optimize the experience of users visiting your site, this book is indispensable.

"If everyone would implement just 20% of Steve's guidelines, the Web would be adramatically better place. Between this book and Steve's YSlow extension, there's reallyno excuse for having a sluggish web site anymore."

-Joe Hewitt, Developer of Firebug debugger and Mozilla's DOM Inspector

"Steve Souders has done a fantastic job of distilling a massive, semi-arcane art down to a set of concise, actionable, pragmatic engineering steps that will change the world of web performance."

-Eric Lawrence, Developer of the Fiddler Web Debugger, Microsoft Corporation

Table of Contents

  1. Praise for High Performance Web Sites
  2. Foreword
  3. Preface
    1. How This Book Is Organized
    2. Conventions Used in This Book
    3. Code Examples
    4. Comments and Questions
    5. Safari® Books Online
    6. Acknowledgments
  4. 1. The Importance of Frontend Performance
    1. Tracking Web Page Performance
    2. Where Does the Time Go?
    3. The Performance Golden Rule
  5. 2. HTTP Overview
    1. Compression
    2. Conditional GET Requests
    3. Expires
    4. Keep-Alive
    5. There’s More
  6. 3. Rule 1: Make Fewer HTTP Requests
    1. Image Maps
    2. CSS Sprites
    3. Inline Images
    4. Combined Scripts and Stylesheets
    5. Conclusion
  7. 4. Rule 2: Use a Content Delivery Network
    1. Content Delivery Networks
    2. The Savings
  8. 5. Rule 3: Add an Expires Header
    1. Expires Header
    2. Max-Age and mod_expires
    3. Empty Cache vs. Primed Cache
    4. More Than Just Images
    5. Revving Filenames
    6. Examples
  9. 6. Rule 4: Gzip Components
    1. How Compression Works
    2. What to Compress
    3. The Savings
    4. Configuration
      1. Apache 1.3: mod_gzip
      2. Apache 2.x: mod_deflate
    5. Proxy Caching
    6. Edge Cases
    7. Gzip in Action
  10. 7. Rule 5: Put Stylesheets at the Top
    1. Progressive Rendering
    2. sleep.cgi
    3. Blank White Screen
      1. CSS at the Bottom
      2. CSS at the Top
    4. Flash of Unstyled Content
    5. What’s a Frontend Engineer to Do?
  11. 8. Rule 6: Put Scripts at the Bottom
    1. Problems with Scripts
    2. Parallel Downloads
    3. Scripts Block Downloads
    4. Worst Case: Scripts at the Top
    5. Best Case: Scripts at the Bottom
    6. Putting It in Perspective
  12. 9. Rule 7: Avoid CSS Expressions
    1. Updating Expressions
    2. Working Around the Problem
      1. One-Time Expressions
      2. Event Handlers
    3. Conclusion
  13. 10. Rule 8: Make JavaScript and CSS External
    1. Inline vs. External
      1. In Raw Terms, Inline Is Faster
      2. Page Views
      3. Empty Cache vs. Primed Cache
      4. Component Reuse
    2. Typical Results in the Field
    3. Home Pages
    4. The Best of Both Worlds
      1. Post-Onload Download
      2. Dynamic Inlining
  14. 11. Rule 9: Reduce DNS Lookups
    1. DNS Caching and TTLs
      1. Factors Affecting DNS Caching
      2. TTL Values
    2. The Browser’s Perspective
      1. Internet Explorer
      2. Firefox
    3. Reducing DNS Lookups
  15. 12. Rule 10: Minify JavaScript
    1. Minification
    2. Obfuscation
    3. The Savings
    4. Examples
    5. Icing on the Cake
      1. Inline Scripts
      2. Gzip and Minification
      3. Minifying CSS
  16. 13. Rule 11: Avoid Redirects
    1. Types of Redirects
    2. How Redirects Hurt Performance
    3. Alternatives to Redirects
      1. Missing Trailing Slash
      2. Connecting Web Sites
      3. Tracking Internal Traffic
      4. Tracking Outbound Traffic
      5. Prettier URLs
  17. 14. Rule 12: Remove Duplicate Scripts
    1. Duplicate Scripts—They Happen
    2. Duplicate Scripts Hurt Performance
    3. Avoiding Duplicate Scripts
  18. 15. Rule 13: Configure ETags
    1. What’s an ETag?
      1. Expires Header
      2. Conditional GET Requests
      3. Last-Modified Date
      4. Entity Tags
    2. The Problem with ETags
    3. ETags: Use ‘Em or Lose ‘Em
    4. ETags in the Real World
  19. 16. Rule 14: Make Ajax Cacheable
    1. Web 2.0, DHTML, and Ajax
      1. Web 2.0
      2. DHTML
      3. Ajax
    2. Asynchronous = Instantaneous?
    3. Optimizing Ajax Requests
    4. Caching Ajax in the Real World
      1. Yahoo! Mail
      2. Google Spreadsheets
  20. 17. Deconstructing 10 Top Sites
    1. Page Weight, Response Time, YSlow Grade
    2. How the Tests Were Done
    3. Amazon
    4. AOL
    5. CNN
    6. eBay
    7. Google
    8. MSN
    9. MySpace
    10. Wikipedia
    11. Yahoo!
    12. YouTube
  21. Index
  22. About the Author
  23. Colophon
  24. Copyright