at random and always test them • For each user, decide at random if they should be tested 11 Performance Optimisation - Fabio Cicerchia http://tech.bluesmoon.info/2010/01/statistics-of-performance-measurement.html http://xkcd.com/221/
by outliers Median(10, 11, 12, 11, 109) = 11 Central tendency Mode(10, 11, 12, 11, 109) = 11 Most recurring value, not often used 12 Performance Optimisation - Fabio Cicerchia
3 components: • The time the request takes to reach the web server • The time the web server takes to process the request and generate the response • The time the response takes to go back to your browser 17 Performance Optimisation - Fabio Cicerchia https://moz.com/blog/improving-search-rank-by-optimizing-your-time-to-first-byte
To Last Byte could be: • Geographic latency (server is far away from visitor) • Poorly written server-side code • Outdated server hardware • Overloaded servers (clogged bandwidth due to high traffic – from humans, bots, or both) • Poorly organized databases • Poorly written database code 18 Performance Optimisation - Fabio Cicerchia
been completely loaded and parsed, without waiting for stylesheets, images, and subframes to finish loading. A very different event load should be used only to detect a fully-loaded page. It is an incredibly popular mistake to use load where DOMContentLoaded would be much more appropriate, so be cautious. 19 Performance Optimisation - Fabio Cicerchia https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded
which visible parts of the page are displayed. It is expressed in milliseconds and dependent on size of the view port. The Speed Index metric measures how quickly the page contents are visually populated (where lower numbers are better). 21 Performance Optimisation - Fabio Cicerchia https://sites.google.com/a/webpagetest.org/docs/using-webpagetest/metrics/speed-index
page requests. They are the single greatest potential point of failure for web pages. 23 Performance Optimisation - Fabio Cicerchia http://www.webperformancetoday.com/2011/07/14/fourth-party-calls-third-party-content/
it will significantly increase the website’s loading speed. • Netflix saw a 43% drop in outbound traffic after enabling compression 24 Performance Optimisation - Fabio Cicerchia https://www.keycdn.com/blog/website-performance-optimization/ https://cdnify.com/blog/15-web-performance-stats/
in customer satisfaction, and 7% loss in conversions 30 Performance Optimisation - Fabio Cicerchia http://www.aberdeen.com/Aberdeen-Library/5136/RA-performance-web-application.aspx
of up to 87%. This is significantly higher than the average abandonment rate of 70%. 31 Performance Optimisation - Fabio Cicerchia https://blog.radware.com/applicationdelivery/applicationaccelerationoptimization/2014/01/55-web-performance-stats-youll-want-to-know/
loads in fewer than 4 seconds on smartphones. 33 Performance Optimisation - Fabio Cicerchia https://blog.radware.com/applicationdelivery/applicationaccelerationoptimization/2014/01/55-web-performance-stats-youll-want-to-know/
than 10 seconds to load. • 20% of the top 100 ecommerce sites loads in more than 10 seconds. 34 Performance Optimisation - Fabio Cicerchia https://blog.radware.com/applicationdelivery/applicationaccelerationoptimization/2014/01/55-web-performance-stats-youll-want-to-know/
comparing sites that load in 5 seconds to sites that load in 19 seconds, the faster sites had 70% longer average session lengths, 35% lower bounce rates and 25% higher ad viewability than their slower counterparts. • Google's DoubleClick found that publishers whose mobile sites load in 5 seconds earn up to 2x more mobile ad revenue than sites loading in 19 seconds. 35 Performance Optimisation - Fabio Cicerchia https://wpostats.com/
experiment revealed that participants had to concentrate up to 50% more when using badly performing websites, while facial muscle and behavioural analysis of the subjects also revealed greater agitation and stress in these periods. 36 Performance Optimisation - Fabio Cicerchia http://www.ca.com/Files/SupportingPieces/final_webstress_survey_report_229296.pdf
scripts should also be minified • The Source Maps are loaded only in Dev Mode 49 Performance Optimisation - Fabio Cicerchia https://www.html5rocks.com/en/tutorials/developertools/sourcemaps/
is a 404, the browser will still try to parse it and find something usable in it • They’ll slow down the UX 50 Performance Optimisation - Fabio Cicerchia
for web • Use the right file format: GIF for animations, JPEG for photograph, otherwise PNG • Don’t Scale Images in HTML 51 Performance Optimisation - Fabio Cicerchia http://www.creativebloq.com/netmag/10-ways-optimise-images-better-performance-71515792
Delivery Network • Add an Expires or a Cache-Control 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 and CSS • Avoid Redirects • Remove Duplicate Scripts • Configure ETags • Make AJAX Cacheable • Use GET for AJAX Requests • Reduce the Number of DOM Elements • No 404s • Reduce Cookie Size • Use Cookie-Free Domains for Components • Avoid Filters • Do Not Scale Images in HTML • Make favicon.ico Small & Cacheable Google’s Rules • Avoid bad requests • Avoid CSS expressions • Combine external CSS • Combine external JavaScript • Defer loading of JavaScript • Enable compression • Leverage browser caching • Leverage proxy caching • Minify CSS • Minify HTML • Minify JavaScript • Minimize request size • Minimize DNS lookups • Minimize redirects • Optimize images • Optimize the order of styles and scripts • Parallelize downloads across hostnames • Put CSS in the document head • Remove unused CSS • Serve resources from a consistent URL • Serve scaled images • Serve static content from a cookieless domain • Specify a character set early • Specify image dimensions • Use efficient CSS selectors Back to basics 53 Performance Optimisation - Fabio Cicerchia http://code.google.com/speed/page-speed/docs/rules_intro.html http://developer.yahoo.com/yslow/help/#guidelines
respond with a 404 • Cookies are sent • Cannot be on CDN • Interferes with the download sequence • Make it small (<= 1K) • Animated favicons are not cool • Set Expires header 55 Performance Optimisation - Fabio Cicerchia
like badges and ads • Security sandbox • You can download scripts in parallel Cons: • They have a cost even if blank • They block page onload • Non-semantic 56 Performance Optimisation - Fabio Cicerchia
(google.com loads a sprite onload) • Conditional preload (search.yahoo.com after you type in the input box) • Anticipated preload – preload in advance before launching a redesign • When you start typing the page can safely assume you’ll hit the search results page Preload Components 58 Performance Optimisation - Fabio Cicerchia
with a web resource • ETags are meant to help with caching ◦ They take precedence for caching ◦ They never expire • Issues with load balanced environment ◦ A component served from server A has a different ETag than the same component served from B • Most of the time you don’t need them 60 Performance Optimisation - Fabio Cicerchia https://techpunch.co.uk/development/should-your-site-be-using-etags-or-not https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching
as low as possible to minimize the impact on the user response time • Be mindful of setting cookies at the appropriate domain level so other sub-domains are not affected • Set an Expires date appropriately. An earlier Expires date or none removes the cookie sooner, improving the user response time 61 Performance Optimisation - Fabio Cicerchia
up, so use delegation (attach listeners to outer elements) • Clean up to prevent IE memory leaks • Careful with onresize Event Handlers 62 Performance Optimisation - Fabio Cicerchia
parallel downloads • In IE @import is the same as putting <link> at the bottom • <link> allows alternate styles (e.g. for accessibility) Choose <link> over @import 63 Performance Optimisation - Fabio Cicerchia http://www.stevesouders.com/blog/2009/04/09/dont-use-import/ http://alistapart.com/article/alternate
means more bytes to download, it also means slower DOM access in JavaScript Easy to test, just type in Firebug’s console: document.getElementsByTagName('*').length 65 Performance Optimisation - Fabio Cicerchia
→ resolve the DNS + TCP handshake + TLS negotiation (optional) • Prefetch → requesting, downloading and storing the asset in the cache • Prerender → load all of the assets of a certain document 66 Performance Optimisation - Fabio Cicerchia https://css-tricks.com/prefetching-preloading-prebrowsing/
the top of the webpage Make sure to render the Above The Fold content in < 1s Defer the non-AFT contents 67 Performance Optimisation - Fabio Cicerchia http://whereisthefold.com/
across multiple domains, improving page load time. When multiple domains are used, browsers are able to download more resources simultaneously, resulting in a faster user experience. Note: HTTP/2 has officially replaced SPDY and made it obsolete. 68 Performance Optimisation - Fabio Cicerchia https://www.maxcdn.com/one/visual-glossary/domain-sharding-2/ https://www.stevesouders.com/blog/2013/09/05/domain-sharding-revisited/
lossless and lossy compression for images on the web. WebP lossless images are 26% smaller than PNGs and 25-34% smaller than JPEG images. 72 Performance Optimisation - Fabio Cicerchia https://developers.google.com/speed/webp/docs/webp_lossless_alpha_study https://developers.google.com/speed/webp/
Use requestAnimationFrame • Have a look at GSAP (20x faster than jQuery) and VelocityJS 73 Performance Optimisation - Fabio Cicerchia https://developers.google.com/web/fundamentals/design-and-ui/animations/animations-and-performance https://developer.mozilla.org/en-US/Apps/Fundamentals/Performance/CSS_JavaScript_animation_performance https://greensock.com/js/speed.html http://velocityjs.org
display of content that relates to the current user action. Perceived Performance is a measure of how quick a user thinks your site is 75 Performance Optimisation - Fabio Cicerchia https://developers.google.com/web/fundamentals/performance/critical-rendering-path/ https://www.smashingmagazine.com/2015/08/understanding-critical-css/ http://blog.teamtreehouse.com/perceived-performance
transmit a single piece of data from one location to another 1. Decrease External HTTP Requests 2. DNS Prefetching 3. Preconnect 4. Use a CDN 5. HTTP/2 6. Caching 77 Performance Optimisation - Fabio Cicerchia https://www.keycdn.com/blog/latency-optimization/
time. The hard part is to reduce the miss rate. What can you cache? • DB Results • Functions Output • Generated HTML Cache 80 Performance Optimisation - Fabio Cicerchia https://www.digitalocean.com/community/tutorials/web-caching-basics-terminology-http-headers-and-caching-strategies https://www.mnot.net/cache_docs/
in one TCP session. • Reduces the bandwidth used by HTTP (header compression & cleaning useless headers). • Makes SSL the underlying transport protocol, for better security and compatibility with existing network infrastructure. 82 Performance Optimisation - Fabio Cicerchia https://www.chromium.org/spdy/spdy-whitepaper
protocol designed for ◦ Low latency transport of content over the Web • No change to HTTP semantics ◦ It’s about how data travels through the wire • Key new features in HTTP/2 ◦ Multiplexing: multiple streams over a single connection ◦ Header compression: reuse headers from previous requests ◦ Server push: multiple parallel responses for a single request ◦ Prioritisation: some resources have priorities 83 Performance Optimisation - Fabio Cicerchia http://www.slideshare.net/nakov/http2-for-developers
(~5KB) it can be very slow. • Making lots of short requests over HTTPS will be quite a bit slower than HTTP, but if you transfer a lot of data in a single request, the difference will be insignificant. • Solution: Improve the Handshake + Keep-Alive. 85 Performance Optimisation - Fabio Cicerchia https://www.maxcdn.com/blog/ssl-performance-myth/ https://unhandledexpression.com/2013/01/25/5-easy-tips-to-accelerate-ssl/ http://blog.haproxy.com/2011/09/16/benchmarking_ssl_performance/
Web Apps, with an emphasis on the performance of app delivery and launch. It stands for: • Push, critical resources for the initial URL route. • Render, initial route. • Pre-cache, remaining routes. • Lazy-load, and create remaining routes on demand. 92 Performance Optimisation - Fabio Cicerchia https://developers.google.com/web/fundamentals/performance/prpl-pattern/
static content that render fast — Google Accelerated Mobile Pages in Google Index: • 600 million AMP Pages • 700,000 Domains • 100+ Languages 93 Performance Optimisation - Fabio Cicerchia
faster, and use eight times less data than traditional mobile optimized pages — Jon Parise (Product Engineer, Pinterest) 94 Performance Optimisation - Fabio Cicerchia https://engineering.pinterest.com/blog/building-faster-mobile-web-experience-amp
server that retrieves resources on behalf of a client from one or more servers. These resources are then returned to the client as if they originated from the proxy server itself. Common choices: • Varnish • Squid • HAProxy • Nginx 98 Performance Optimisation - Fabio Cicerchia https://en.wikipedia.org/wiki/Reverse_proxy http://stackoverflow.com/questions/224664/difference-between-proxy-server-and-reverse-proxy-server