1.27k likes | 1.39k Vues
In this presentation from Yahoo! HighLoad++ Moscow 2010, Stoyan Stefanov explores the significance of progressive downloads and rendering for optimizing web performance. The discussion covers the psychological impacts of perceived wait times and practical solutions for reducing HTTP requests. Key strategies include leveraging Gzip, image minification, CDN usage, and optimizing JavaScript and CSS loading. By adopting progressive enhancement techniques, developers can ensure faster content delivery, improve user experience, and ultimately "make people happy." Learn essential best practices to enhance performance effectively.
E N D
Progressive downloads and rendering Stoyan Stefanov, Yahoo! HighLoad++, Moscow, 2010 http://slideshare.net/stoyan/
About me YSlow 2.0
Importance of performance Psychology, physiology Effects of waiting “Time is money” Make people happy
Time is relative Sometimes crawls Sometimes flies “it depends”
Durations actual expected perceived rem’d time
It feels slower when… Unpleasant Unknown Boring Too much to keep track
First time experience Unfamiliar = slow Optimize empty cache or there will be no full cache
The basics Reducing the # HTTP Gzip Minification Image smushing Expires CDN
The basics Yahoo!’s best practices + YSlow http://developer.yahoo.com/performance/ Google’s too + Page Speed http://code.google.com/speed/
Agenda Prevent download blocks: scripts, styles, CC, favicon Ways to render sooner: flush, data URIs, lazy loading, lazy evaluation, preloading, animations
JavaScript blocks html js png png
JavaScript blocks A no-no! <script src="jquery.js"></script> <script src="jquery.twitter.js"></script> <script src="jquery.cookie.js"></script> <script src="myapp.js"></script>
This waterfall looks ridiculous html js js js js png png
JavaScript at the bottom html png png js
Non-blocking JavaScript deferand async Defer: IE innovation, ok to delay, but keep order Async: HTML5, whatever <script asyncsrc="my.js" onload="doIt()"></script> <script defer src="my.js" onload="doIt()"></script>
defer and async timeline async defer DOMContentLoaded load
Non-blocking JavaScript html js png Asynchronous loading varh, js= document.createElement('script'); js.src = 'myscript.js'; h= document.getElementsByTagName('head')[0]; h.appendChild(js); png
Non-blocking JavaScript Others: - iframe - XHR - <object> - …
Worst enemy? CSS
CSS blocks rendering The worst component type Place way at the top @media print, etc in the same external CSS http://www.phpied.com/delay-loading-your-print-css/ http://www.phpied.com/rendering-styles/
CSS blockdownloads? But they do block: When followed by an inline script When in conditional comments
Inline CSS Google search Bing.com: inline + postload
Same domain If you split across domains and if you don’t use CDN Saves a DNS lookup e.g. Google and Bing’s CDN
With conditionally commented CSS file http://www.phpied.com/conditional-comments-block-downloads/
What…?! Case #1 <link type="text/css" rel="stylesheet" href="1.css"> <!--[if IE 6]> <link type="text/css" rel="stylesheet" href="ie.css"> <![endif]-->
What…?! Case #2 <!--[if IE 6]> <body class="ie6"> <![endif]--> <!--[if !IE]><!--> <body> <!--<![endif]-->
Solution for case #1 <!DOCTYPE html> <!--[if IE 6]><![endif]--> <html> ...
Solution for case #2 <!--[if IE 6]> <html class="ie6"> <![endif]--> <!--[if !IE]><!--> <html> <!--<![endif]-->