12. On trade-offs
“…everything has its drawbacks,
as the man said when his
mother-in-law died, and they
came upon him for the funeral
expenses”
Jerome K. Jerome
Three man in a boat
13. The Life of Page 2.0
HTML page
request onload settles request
sent
marriage? R.I.P.
conception birth graduation
User perceived
“onload” happens
somewhere here
50. Gzip or minification?
• 62,885 bytes - original jQuery (back in
Aug 2007)
• 31,822 - minified with the YUI
Compressor
• 19,758 - original gzipped
• 10,818 - minified and gzipped FTW
http://www.julienlecomte.net/blog/2007/08/13/
57. Images Loss-
1. No GIFs, PNG8 less
2. Crush PNGs
3. run JPEGs through jpegtran
4. Gifsicle for animations
http://yuiblog.com/blog/2008/11/14/imageopt-3/
60. Images – duh!
1. Don’t scale in HTML
2. Generated images should
be crushed PNGs too
61. Images
• It’s only human to forget
• All you need is a process so
you don’t have to
remember
62. 204
• The world’s smallest component?
• 204 No Content
<?php
header("HTTP/1.0 204 No Content");
// .... do your job, e.g. logging
?>
http://www.phpied.com/204-no-content/
68. Non-blocking JavaScript
• Include via DOM
html
js
png
png
var js = document.createElement('script');
js.src = 'myscript.js';
var h = document.getElementsByTagName('head')[0];
h.appendChild(js);
96. Rendering
• CSS on top
• No separate print CSS
• CSS refactoring
• No AlphaImageLoader
• Expensive elements
• No CSS expressions
• Image dimensions
97. CSS early on
• No separate print CSS file
/* screen styles */
#nav {...}
.banner {...}
/* print styles */
@media print {
#nav {display: none}
.banner {display: none;}
}
98. CSS refactoring
• CSS tends to grow
• Find unused selectors –
DustMeSelectors extension
• Cleanup things like:
#header #menu {...}
div#menu {...}
ul li {...}
105. Yahoo! performance rules
1. Make Fewer HTTP Requests 19. Reduce the Number of DOM Elements
2. Use a Content Delivery Network 20. Split Components Across Domains
3. Add an Expires or a Cache-Control 21. Minimize the Number of iframes
Header 22. No 404s
4. Gzip Components 23. Reduce Cookie Size
5. Put Stylesheets at the Top 24. Use Cookie-free Domains for
6. Put Scripts at the Bottom Components
7. Avoid CSS Expressions 25. Minimize DOM Access
8. Make JavaScript and CSS External 26. Develop Smart Event Handlers
9. Reduce DNS Lookups 27. Choose <link> over @import
10. Minify JavaScript and CSS 28. Avoid Filters
11. Avoid Redirects 29. Optimize Images
12. Remove Duplicate JS and CSS 30. Optimize CSS Sprites
13. Configure ETags 31. Don't Scale Images in HTML
14. Make Ajax Cacheable 32. Make favicon.ico Small and
15. Flush the Buffer Early Cacheable
16. Use GET for AJAX Requests 33. Keep Components under 25K
17. Post-load Components 34. Pack Components into a Multipart
Document
18. Preload Components
106. YSlow 1.0. rules
1. Make Fewer HTTP Requests 19. Reduce the Number of DOM Elements
2. Use a Content Delivery Network 20. Split Components Across Domains
3. Add an Expires or a Cache-Control 21. Minimize the Number of iframes
Header 22. No 404s
4. Gzip Components 23. Reduce Cookie Size
5. Put Stylesheets at the Top 24. Use Cookie-free Domains for
6. Put Scripts at the Bottom Components
7. Avoid CSS Expressions 25. Minimize DOM Access
8. Make JavaScript and CSS External 26. Develop Smart Event Handlers
9. Reduce DNS Lookups 27. Choose <link> over @import
10. Minify JavaScript and CSS 28. Avoid Filters
11. Avoid Redirects 29. Optimize Images
12. Remove Duplicate JS and CSS 30. Optimize CSS Sprites
13. Configure ETags 31. Don't Scale Images in HTML
14. Make Ajax Cacheable 32. Make favicon.ico Small and
15. Flush the Buffer Early Cacheable
16. Use GET for AJAX Requests 33. Keep Components under 25K
17. Post-load Components 34. Pack Components into a Multipart
Document
18. Preload Components
107. YSlow 2.0. rules
1. Make Fewer HTTP Requests 19. Reduce the Number of DOM Elements
2. Use a Content Delivery Network 20. Split Components Across Domains
3. Add an Expires or a Cache-Control 21. Minimize the Number of iframes
Header 22. No 404s
4. Gzip Components 23. Reduce Cookie Size
5. Put Stylesheets at the Top 24. Use Cookie-free Domains for
6. Put Scripts at the Bottom Components
7. Avoid CSS Expressions 25. Minimize DOM Access
8. Make JavaScript and CSS External 26. Develop Smart Event Handlers
9. Reduce DNS Lookups 27. Choose <link> over @import
10. Minify JavaScript and CSS 28. Avoid Filters
11. Avoid Redirects 29. Optimize Images
12. Remove Duplicate JS and CSS 30. Optimize CSS Sprites
13. Configure ETags 31. Don't Scale Images in HTML
14. Make Ajax Cacheable 32. Make favicon.ico Small and
15. Flush the Buffer Early Cacheable
16. Use GET for AJAX Requests 33. Keep Components under 25K
17. Post-load Components 34. Pack Components into a Multipart
Document
18. Preload Components
108. YSlow 1.0. rule weights
1. Make Fewer HTTP Requests 8
2. Use a Content Delivery Network 6
3. Add an Expires or a Cache-Control Header 10
4. Gzip Components 8
5. Put Stylesheets at the Top 4
6. Put Scripts at the Bottom 4
7. Avoid CSS Expressions 3
8. Make JavaScript and CSS External 4
9. Reduce DNS Lookups 3
10. Minify JavaScript 4
11. Avoid Redirects 4
12. Remove Duplicate JS 4
13. Configure Etags 2
109. YSlow 2.0. rule weights
1. Make Fewer HTTP Requests 8
2. Use a Content Delivery Network 6
3. Add an Expires or a Cache-Control Header 10
4. Gzip Components 8
5. Put Stylesheets at the Top 4
6. Put Scripts at the Bottom 4
7. Avoid CSS Expressions 3
8. Make JavaScript and CSS External 4
9. Reduce DNS Lookups 3
10. Minify JavaScript and CSS 4
11. Avoid Redirects 4
12. Remove Duplicate JS and CSS 4
13. Configure Etags 2
14. Make Ajax Cacheable 4
16. Use GET for AJAX Requests 3
19. Reduce the Number of DOM Elements 3
22. No 404s 4
23. Reduce Cookie Size 3
24. Use Cookie-free Domains for Components 3
28. Avoid Filters 4
31. Don't Scale Images in HTML 3
32. Make favicon.ico Small and Cacheable 2
110. YSlow score
foreach rule
total += rule score * rule weight
end foreach
score = total / sum of rule weights
114. Rule penalties
1. Make Fewer HTTP Requests
2. Use a Content Delivery Network
3. Add an Expires or a Cache-Control Header
4. Gzip Components
5. Put Stylesheets at the Top
6. Put Scripts at the Bottom
7. Avoid CSS Expressions
8. Make JavaScript and CSS External # ok -points
9. Reduce DNS Lookups
10. Minify JavaScript and CSS JS 3 -4/off
11. Avoid Redirects
CSS 2 -4/off
12. Remove Duplicate JS and CSS
13. Configure Etags img 6 -3/off
14. Make Ajax Cacheable
16. Use GET for AJAX Requests
19. Reduce the Number of DOM Elements
22. No 404s
23. Reduce Cookie Size
24. Use Cookie-free Domains for Components
28. Avoid Filters
31. Don't Scale Images in HTML
32. Make favicon.ico Small and Cacheable
115. Rule penalties
1. Make Fewer HTTP Requests
2. Use a Content Delivery Network
3. Add an Expires or a Cache-Control Header
4. Gzip Components
5. Put Stylesheets at the Top
6. Put Scripts at the Bottom
7. Avoid CSS Expressions
8. Make JavaScript and CSS External
9. Reduce DNS Lookups
10. Minify JavaScript and CSS
11. Avoid Redirects -10 points
12. Remove Duplicate JS and CSS
13. Configure Etags
per
14. Make Ajax Cacheable offending
16. Use GET for AJAX Requests component
19. Reduce the Number of DOM Elements
22. No 404s
23. Reduce Cookie Size
24. Use Cookie-free Domains for Components
28. Avoid Filters
31. Don't Scale Images in HTML
32. Make favicon.ico Small and Cacheable
116. Rule penalties
1. Make Fewer HTTP Requests
2. Use a Content Delivery Network
3. Add Expires Headers
4. Gzip Components
5. Put Stylesheets at the Top
6. Put Scripts at the Bottom
7. Avoid CSS Expressions
8. Make JavaScript and CSS External
9. Reduce DNS Lookups
10. Minify JavaScript and CSS If expiration
11. Avoid Redirects is less than
12. Remove Duplicate JS and CSS
13. Configure Etags
2 days
14. Make Ajax Cacheable subtract -11
16. Use GET for AJAX Requests points per
19. Reduce the Number of DOM Elements
component
22. No 404s
23. Reduce Cookie Size
24. Use Cookie-free Domains for Components
28. Avoid Filters
31. Don't Scale Images in HTML
32. Make favicon.ico Small and Cacheable
117. Rule penalties
1. Make Fewer HTTP Requests
2. Use a Content Delivery Network
3. Add an Expires or a Cache-Control Header
4. Gzip Components
5. Put Stylesheets at the Top
6. Put Scripts at the Bottom
7. Avoid CSS Expressions
8. Make JavaScript and CSS External
9. Reduce DNS Lookups
10. Minify JavaScript and CSS -11 points
11. Avoid Redirects per
12. Remove Duplicate JS and CSS
13. Configure Etags
offending
14. Make Ajax Cacheable component
16. Use GET for AJAX Requests bigger than
19. Reduce the Number of DOM Elements
500 bytes
22. No 404s
23. Reduce Cookie Size
24. Use Cookie-free Domains for Components
28. Avoid Filters
31. Don't Scale Images in HTML
32. Make favicon.ico Small and Cacheable
118. Rule penalties
1. Make Fewer HTTP Requests
2. Use a Content Delivery Network
3. Add an Expires or a Cache-Control Header
4. Gzip Components
5. Put Stylesheets at the Top
6. Put Scripts at the Bottom
7. Avoid CSS Expressions
8. Make JavaScript and CSS External
9. Reduce DNS Lookups
10. Minify JavaScript and CSS
11. Avoid Redirects -10 points
12. Remove Duplicate JS and CSS
13. Configure Etags
per
14. Make Ajax Cacheable offending
16. Use GET for AJAX Requests component
19. Reduce the Number of DOM Elements
22. No 404s
23. Reduce Cookie Size
24. Use Cookie-free Domains for Components
28. Avoid Filters
31. Don't Scale Images in HTML
32. Make favicon.ico Small and Cacheable
119. Rule penalties
1. Make Fewer HTTP Requests
2. Use a Content Delivery Network
3. Add an Expires or a Cache-Control Header
4. Gzip Components
5. Put Stylesheets at the Top
6. Put Scripts at the Bottom
7. Avoid CSS Expressions
8. Make JavaScript and CSS External
9. Reduce DNS Lookups
10. Minify JavaScript and CSS
11. Avoid Redirects -5 points
12. Remove Duplicate JS and CSS
13. Configure Etags
per
14. Make Ajax Cacheable offending
16. Use GET for AJAX Requests component
19. Reduce the Number of DOM Elements
22. No 404s
23. Reduce Cookie Size
24. Use Cookie-free Domains for Components
28. Avoid Filters
31. Don't Scale Images in HTML
32. Make favicon.ico Small and Cacheable
120. Rule penalties
1. Make Fewer HTTP Requests
2. Use a Content Delivery Network
3. Add an Expires or a Cache-Control Header
4. Gzip Components
5. Put Stylesheets at the Top
6. Put Scripts at the Bottom
7. Avoid CSS Expressions
8. Make JavaScript and CSS External
9. Reduce DNS Lookups
10. Minify JavaScript and CSS
11. Avoid Redirects
12. Remove Duplicate JS and CSS -2 points
13. Configure Etags per
Make Ajax Cacheable
14.
16. Use GET for AJAX Requests
expression
19. Reduce the Number of DOM Elements
22. No 404s
23. Reduce Cookie Size
24. Use Cookie-free Domains for Components
28. Avoid Filters
31. Don't Scale Images in HTML
32. Make favicon.ico Small and Cacheable
121. Rule penalties
1. Make Fewer HTTP Requests
2. Use a Content Delivery Network
3. Add an Expires or a Cache-Control Header
4. Gzip Components
5. Put Stylesheets at the Top
6. Put Scripts at the Bottom
7. Avoid CSS Expressions
8. Make JS and CSS External
9. Reduce DNS Lookups
10. Minify JavaScript and CSS
11. Avoid Redirects
12. Remove Duplicate JS and CSS
13. Configure Etags
14. Make Ajax Cacheable Score is
16. Use GET for AJAX Requests always n/a
19. Reduce the Number of DOM Elements
22. No 404s
23. Reduce Cookie Size
24. Use Cookie-free Domains for Components
28. Avoid Filters
31. Don't Scale Images in HTML
32. Make favicon.ico Small and Cacheable
122. Rule penalties
1. Make Fewer HTTP Requests
2. Use a Content Delivery Network
3. Add an Expires or a Cache-Control Header
4. Gzip Components
5. Put Stylesheets at the Top
6. Put Scripts at the Bottom
7. Avoid CSS Expressions
8. Make JavaScript and CSS External
9. Reduce DNS Lookups
10. Minify JavaScript and CSS
11. Avoid Redirects
4 domains
12. Remove Duplicate JS and CSS ok
13. Configure Etags -5 points
Make Ajax Cacheable
14.
16. Use GET for AJAX Requests
per domain
19. Reduce the Number of DOM Elements otherwise
22. No 404s
23. Reduce Cookie Size
24. Use Cookie-free Domains for Components
28. Avoid Filters
31. Don't Scale Images in HTML
32. Make favicon.ico Small and Cacheable
123. Rule penalties
1. Make Fewer HTTP Requests
2. Use a Content Delivery Network
3. Add an Expires or a Cache-Control Header
4. Gzip Components
5. Put Stylesheets at the Top
6. Put Scripts at the Bottom
7. Avoid CSS Expressions
8. Make JavaScript and CSS External
9. Reduce DNS Lookups
10. Minify -10 points
11. Avoid Redirects
12. Remove Duplicate JS and CSS per
13. Configure Etags offender,
Make Ajax Cacheable
14.
16. Use GET for AJAX Requests
including
19. Reduce the Number of DOM Elements inline
22. No 404s
23. Reduce Cookie Size
24. Use Cookie-free Domains for Components
28. Avoid Filters
31. Don't Scale Images in HTML
32. Make favicon.ico Small and Cacheable
124. Rule penalties
1. Make Fewer HTTP Requests
2. Use a Content Delivery Network
3. Add an Expires or a Cache-Control Header
4. Gzip Components
5. Put Stylesheets at the Top
6. Put Scripts at the Bottom
7. Avoid CSS Expressions
8. Make JavaScript and CSS External
9. Reduce DNS Lookups
10. Minify JavaScript and CSS
11. Avoid Redirects
12. Remove Duplicate JS and CSS
13. Configure Etags
-10 points
14. Make Ajax Cacheable per redirect
16. Use GET for AJAX Requests
19. Reduce the Number of DOM Elements
22. No 404s
23. Reduce Cookie Size
24. Use Cookie-free Domains for Components
28. Avoid Filters
31. Don't Scale Images in HTML
32. Make favicon.ico Small and Cacheable
125. Rule penalties
1. Make Fewer HTTP Requests
2. Use a Content Delivery Network
3. Add an Expires or a Cache-Control Header
4. Gzip Components
5. Put Stylesheets at the Top
6. Put Scripts at the Bottom
7. Avoid CSS Expressions
8. Make JavaScript and CSS External
9. Reduce DNS Lookups
10. Minify JavaScript and CSS
11. Avoid Redirects
12. No Duplicates -5 points
per
13. Configure Etags
14. Make Ajax Cacheable duplicate
16. Use GET for AJAX Requests JS or CSS
19. Reduce the Number of DOM Elements
22. No 404s
23. Reduce Cookie Size
24. Use Cookie-free Domains for Components
28. Avoid Filters
31. Don't Scale Images in HTML
32. Make favicon.ico Small and Cacheable
126. Rule penalties
1. Make Fewer HTTP Requests
2. Use a Content Delivery Network
3. Add an Expires or a Cache-Control Header
4. Gzip Components
5. Put Stylesheets at the Top
6. Put Scripts at the Bottom
7. Avoid CSS Expressions
8. Make JavaScript and CSS External
9. Reduce DNS Lookups
10. Minify JavaScript and CSS
11. Avoid Redirects
12. Remove Duplicate JS and CSS
-11 points
13. Configure ETags per
14. Make Ajax Cacheable offending
16. Use GET for AJAX Requests component
19. Reduce the Number of DOM Elements
22. No 404s
23. Reduce Cookie Size
24. Use Cookie-free Domains for Components
28. Avoid Filters
31. Don't Scale Images in HTML
32. Make favicon.ico Small and Cacheable
127. Rule penalties
1. Make Fewer HTTP Requests
2. Use a Content Delivery Network
3. Add an Expires or a Cache-Control Header
4. Gzip Components
5. Put Stylesheets at the Top
6. Put Scripts at the Bottom -5 points
7. Avoid CSS Expressions
8. Make JavaScript and CSS External
per XHR
9. Reduce DNS Lookups without at
10. Minify JavaScript and CSS least 1 hour
11. Avoid Redirects
expiration
12. Remove Duplicate JS and CSS
13. Configure Etags
14. Make Ajax Cacheable
16. Use GET for AJAX Requests
19. Reduce the Number of DOM Elements
22. No 404s
23. Reduce Cookie Size
24. Use Cookie-free Domains for Components
28. Avoid Filters
31. Don't Scale Images in HTML
32. Make favicon.ico Small and Cacheable
128. Rule penalties
1. Make Fewer HTTP Requests
2. Use a Content Delivery Network
3. Add an Expires or a Cache-Control Header
4. Gzip Components
5. Put Stylesheets at the Top -5 points
6. Put Scripts at the Bottom per
7. Avoid CSS Expressions
8. Make JavaScript and CSS External
non-GET
9. Reduce DNS Lookups XHR
10. Minify JavaScript and CSS
11. Avoid Redirects
12. Remove Duplicate JS and CSS
13. Configure Etags
14. Make Ajax Cacheable
16. Use GET for AJAX Requests
19. Reduce the Number of DOM Elements
22. No 404s
23. Reduce Cookie Size
24. Use Cookie-free Domains for Components
28. Avoid Filters
31. Don't Scale Images in HTML
32. Make favicon.ico Small and Cacheable
129. Rule penalties
1. Make Fewer HTTP Requests
2. Use a Content Delivery Network
3. Add an Expires or a Cache-Control Header
4. Gzip Components
5. Put Stylesheets at the Top -10 points
6. Put Scripts at the Bottom
7. Avoid CSS Expressions
for every
8. Make JavaScript and CSS External 250
9. Reduce DNS Lookups elements
10. Minify JavaScript and CSS
over 900
11. Avoid Redirects
12. Remove Duplicate JS and CSS
13. Configure Etags
14. Make Ajax Cacheable
16. Use GET for AJAX Requests
19. Reduce # of DOM Elements
22. No 404s
23. Reduce Cookie Size
24. Use Cookie-free Domains for Components
28. Avoid Filters
31. Don't Scale Images in HTML
32. Make favicon.ico Small and Cacheable
130. Rule penalties
1. Make Fewer HTTP Requests
2. Use a Content Delivery Network
3. Add an Expires or a Cache-Control Header
4. Gzip Components
5. Put Stylesheets at the Top
6. Put Scripts at the Bottom
7. Avoid CSS Expressions
8. Make JavaScript and CSS External
9. Reduce DNS Lookups
10. Minify JavaScript and CSS
11. Avoid Redirects
12. Remove Duplicate JS and CSS
13. Configure Etags -5 points
14. Make Ajax Cacheable per
16. Use GET for AJAX Requests
19. Reduce the Number of DOM Elements
offending
component
22. No 404s
23. Reduce Cookie Size
24. Use Cookie-free Domains for Components
28. Avoid Filters
31. Don't Scale Images in HTML
32. Make favicon.ico Small and Cacheable
131. Rule penalties
1. Make Fewer HTTP Requests
2. Use a Content Delivery Network
3. Add an Expires or a Cache-Control Header
4. Gzip Components
5. Put Stylesheets at the Top
6. Put Scripts at the Bottom
7. Avoid CSS Expressions
8. Make JavaScript and CSS External
9. Reduce DNS Lookups
10. Minify JavaScript and CSS
11. Avoid Redirects -10 points
12. Remove Duplicate JS and CSS
per
13. Configure Etags
14. Make Ajax Cacheable
component
16. Use GET for AJAX Requests requested
19. Reduce the Number of DOM Elements with over
No 404s
22.
1000 bytes
23. Reduce Cookie Size of cookies
24. Use Cookie-free Domains for Components
28. Avoid Filters
31. Don't Scale Images in HTML
32. Make favicon.ico Small and Cacheable
132. Rule penalties
1. Make Fewer HTTP Requests
2. Use a Content Delivery Network
3. Add an Expires or a Cache-Control Header
4. Gzip Components
5. Put Stylesheets at the Top
6. Put Scripts at the Bottom
7. Avoid CSS Expressions -5 points
8. Make JavaScript and CSS External per
Reduce DNS Lookups
9.
10. Minify JavaScript and CSS
component
11. Avoid Redirects requested
12. Remove Duplicate JS and CSS with a
13. Configure Etags cookie
14. Make Ajax Cacheable
16. Use GET for AJAX Requests
19. Reduce the Number of DOM Elements
22. No 404s
23. Reduce Cookie Size
24. Cookie-free Domains
28. Avoid Filters
31. Don't Scale Images in HTML
32. Make favicon.ico Small and Cacheable
133. Rule penalties
1. Make Fewer HTTP Requests
2. Use a Content Delivery Network
3. Add an Expires or a Cache-Control Header
4. Gzip Components
5. Put Stylesheets at the Top
6. Put Scripts at the Bottom
7. Avoid CSS Expressions
8. Make JavaScript and CSS External
9. Reduce DNS Lookups
10. Minify JavaScript and CSS
11. Avoid Redirects
12. Remove Duplicate JS and CSS
-5 points
13. Configure Etags
14. Make Ajax Cacheable
per offense
16. Use GET for AJAX Requests or
19. Reduce the Number of DOM Elements -2 if using
No 404s
22.
23. Reduce Cookie Size
_filter hack
24. Use Cookie-free Domains for Components
28. Avoid Filters
31. Don't Scale Images in HTML
32. Make favicon.ico Small and Cacheable
134. Rule penalties
1. Make Fewer HTTP Requests
2. Use a Content Delivery Network
3. Add an Expires or a Cache-Control Header
4. Gzip Components
5. Put Stylesheets at the Top
6. Put Scripts at the Bottom
7. Avoid CSS Expressions
8. Make JavaScript and CSS External
9. Reduce DNS Lookups
10. Minify JavaScript and CSS
11. Avoid Redirects
12. Remove Duplicate JS and CSS
13. Configure Etags -5 points
14. Make Ajax Cacheable per scaled
16. Use GET for AJAX Requests
19. Reduce the Number of DOM Elements
down
22. No 404s image
23. Reduce Cookie Size
24. Use Cookie-free Domains for Components
28. Avoid Filters
31. Don't Scale Images in HTML
32. Make favicon.ico Small and Cacheable
135. Rule penalties
1. Make Fewer HTTP Requests
2. Use a Content Delivery Network
3. Add an Expires or a Cache-Control Header
4. Gzip Components
5. Put Stylesheets at the Top
6. Put Scripts at the Bottom
7. Avoid CSS Expressions
8. Make JavaScript and CSS External
9. Reduce DNS Lookups
10. Minify JavaScript and CSS
11. Avoid Redirects
12. Remove Duplicate JS and CSS
-5 points if
13. Configure Etags
14. Make Ajax Cacheable
size is over
16. Use GET for AJAX Requests 2000 bytes
19. Reduce the Number of DOM Elements and -5 if no
No 404s
22.
23. Reduce Cookie Size
expiration
24. Use Cookie-free Domains for Components
28. Avoid Filters
31. Don't Scale Images in HTML
32. Small cacheable favicon
140. It’s a marathon
• Not a sprint
• Measure, monitor, link to
business metrics
• Bugs are expensive as the
time passes, performance
bugs even more so