and Video @zgordon • Even if Site is Optimized it Seems Slow • Server Bandwidth • Slow-Loading or Unexpected Pauses • File Size Limits and Storage Space • Multiple Formats • Varying Quality Across Browsers • Video Players • Piracy Reasons to Host Media with 3rd Parties
Networks @zgordon Content Delivery Networks serve assets for your site from fast, distributed servers. Takes the load off of your server Likely run faster than your server Special deals with ISP Examples: Amazon S3, jQuery
@zgordon To help with performance keep the specificity as general as possible section#page nav.main ul li a.active { do: it; } #main a.active { do: it; } a.active { do: it; } $('section#page nav.main ul li a.active').doIt();
CSS background images into a single image • Use CSS Background position to display correct image • Cuts down on number of requests • Ensure all images are optimized CSS Sprites @zgordon
combines groups of similar files into a single file. Asset Concatenation @zgordon Reduces calls to the server Order of your files and code matters Options: copy and paste v. run script on server
- HTML + PHP @zgordon Browser Caching tell the client how long to cache files and assets for <META HTTP-EQUIV="EXPIRES" CONTENT="Dec, 21 Jul 2013 11:11:11 GMT"> HTML <?php header('Expires: Fri, 26 Jul 2013 05:00:00 GMT'); ?> PHP
- .htaccess @zgordon Browser Caching tell the client how long to cache files and assets for <IfModule mod_expires.c> ExpiresActive On ExpiresByType image/png "access plus 7015 days" ExpiresByType text/css "access plus 2 weeks" ExpiresByType text/x-javascript "modification 1 month" ExpiresDefault "modification 2 days" </IfModule> .htaccess
- Oh No!!! @zgordon If you cache into the distant future there is no real way to stop it. <script type="text/javascript" src="/js/main.js?v=1"></script> So... <script type="text/javascript" src="/js/main.js?v=2"></script> <img src="/img/logo.png?v=2" alt="New logo"> Eh?