web performance mercadolibre - eci 2013
DESCRIPTION
Web performance optimization, frontend optimization, performance best practicesTRANSCRIPT
![Page 1: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/1.jpg)
Techniques, tips and tools for improve and measure web performance.
Web Performance MercadoLibre
Santiago AimettaNicolas Brizuela
![Page 2: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/2.jpg)
Why performance?
Reducing time to response, impact directly in your revenues.
Impact directly in the bounce rate, conversions rate and is very important for user experience.
![Page 3: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/3.jpg)
Some numbers of Meli Search
● 75MM searches/day (870 searches/second)● Peak traffic 102k rpm (1.700 searches/second)● Avg response time: 320ms
![Page 4: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/4.jpg)
Amazon test 2008● + 100ms >> -1% sales
Bing test 2009● + 2000ms >> -4.3% revenues/user
MercadoLibre 2013● + 3000ms >> + 3% in Bounce rate
-1% in Revenues
![Page 5: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/5.jpg)
![Page 6: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/6.jpg)
Performance golden rules
● 80-90% of the end-user response time is spent on the frontend.
We start there● Greater potential● Simple● Proven to work
![Page 7: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/7.jpg)
Responsibilities
![Page 8: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/8.jpg)
![Page 9: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/9.jpg)
Time to First Byte
![Page 10: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/10.jpg)
What is this?Is the amount of time between the client makes an HTTP request and the browser starts receiving the first byte.
How much time is spent making the request until receive the first byte of the response.
![Page 11: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/11.jpg)
1. DNS LOOKUP2. INITIAL CONNECTION3. WAITING4. RECEIVING DATA5. CLOSING CONNECTION
![Page 12: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/12.jpg)
1. DNS LOOKUP2. INITIAL CONNECTION3. WAITING4. RECEIVING DATA5. CLOSING CONNECTION
![Page 13: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/13.jpg)
1. DNS LOOKUP2. INITIAL CONNECTION3. WAITING4. RECEIVING DATA5. CLOSING CONNECTION
![Page 14: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/14.jpg)
1. DNS LOOKUP2. INITIAL CONNECTION3. WAITING4. RECEIVING DATA5. CLOSING CONNECTION
![Page 15: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/15.jpg)
1. DNS LOOKUP2. INITIAL CONNECTION3. WAITING4. RECEIVING DATA5. CLOSING CONNECTION
<< Time to first Byte = TTFB
![Page 16: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/16.jpg)
Expected values
![Page 17: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/17.jpg)
● Static content○ Such as Html, Js, Css and images○ Should be under 100 miliseconds
● Dinamic content○ Includes all the server side processing plus the
network infrastructure work○ Should be beetween 200 and 500 miliseconds
![Page 18: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/18.jpg)
Possible problems
● To many connections to the server● Disk IO
![Page 19: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/19.jpg)
Hardware check..
● Disk IO● RAM usage● Swap usage● Network bottlenecks
![Page 20: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/20.jpg)
Configuration check..
● Webserver config (Apache,Jboss,..) / Php config● Database settings● Network settings● Api / webservices latency
![Page 21: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/21.jpg)
How to improve it?
![Page 22: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/22.jpg)
Hardware
● CDN- Content delivery network (Akamai, CloudFront, BitGravity)
● Multiple servers with load balancing ( f5 , nginx )● NAS - Filers ( T-com, IBM, HP)● Web caches ( Varnish, Polipo, Squid, TrafficServer )
![Page 23: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/23.jpg)
Software
● Parallel processing● Database tuning● Sql tuning● API / Webservices response caching● NoSql (MongoDB, Bigtable, Redis)● Chunking - Early buffer flush
![Page 24: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/24.jpg)
Tools
![Page 25: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/25.jpg)
Analyzers
● Google Page Speed● WebPageTest● Firebug
![Page 26: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/26.jpg)
Custom measuring
● Navigation timing apivar timing = window.performance.timing;var ttfb = timing.responseStart -timing.connectEnd;
![Page 27: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/27.jpg)
CDN (Content Delivery Network)
![Page 28: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/28.jpg)
● Group of servers distributed in multiple datacenters across the internet
● The CDN serves the content using the servers that are closer to the client
● The network latency is reduced by the proximity between client and server.
![Page 29: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/29.jpg)
![Page 30: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/30.jpg)
● The resources can be cached● Multiple servers prevent bottlenecks● Useful for static resources like Html, Css, fonts , Js,
videos , images, documents, etc
![Page 31: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/31.jpg)
GZIP (HTTP compression)
![Page 32: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/32.jpg)
● Type of http compression like deflate● This saves bandwidth and increases speed.● Web client (i.e Browser) sends an Accept-Encoding :
gzip, deflate header● Web server responds Content-Encoding : gzip if the
data is compressed
![Page 33: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/33.jpg)
![Page 34: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/34.jpg)
● Reduce the 70%-90% of the response size● Use in Html, Css, Js, Xml, Json● Dont use in Pdf and images, they are already
compressed
● Better compression tips:○ Sorted key values : Css, html attributes○ use one type of quotes, " or '○ Css and Js minification
![Page 35: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/35.jpg)
Cache
![Page 36: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/36.jpg)
Benefits
● Saves requests to resources that changes infrequently.
● HTTP caching saves the resources in the browser or the proxy.
● Should be cached: CSS, JS, Static HTML, Images, Flash, Pdf, media files.
![Page 37: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/37.jpg)
How it works?
![Page 38: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/38.jpg)
How it works?
![Page 39: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/39.jpg)
Response Headers
● Strong ones:
○ These headers express the resource lifetime.○ The value is a date or a timestamp.○ A resource is downloaded again when the
expiration date is reached.○ Expires and Cache Control.
![Page 40: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/40.jpg)
Response Headers
● Weak ones:
○ Specifies characteristics to identify if the resource change
○ The browser sends conditional GETs to check○ Last-Modified, Etag
![Page 41: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/41.jpg)
Cache Control
● Strong header● Cache-Control:public● Cache-Control:private● i.e: Cache-Control:public, max-age=3600
![Page 42: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/42.jpg)
Expires
● Sets an expiration date in the future.● if Cache-control and expires are set for the same.
resource Cache-control takes precedence.● i.e: Expires: Mon, 8 Jul 2013 21:31:12 GMT.
![Page 43: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/43.jpg)
Last modified
● Is a time based header.
● The application specifies the last modified headeri.e: Last-Modified: Tue, 09 jul 2013 17:45:57 GMT.
● The next time the browser sends a conditional GET asking if the resource has changedi.e If-Modified-Since: Tue, 09 jul 2013 17:45:57 GMT.
● If the resource hasn't changed the server return an empty response with the 304 code (Not Modified)
![Page 44: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/44.jpg)
Etag
● Use an md5 hash to identify if the resource change.ETag: "15f0fff99ed5aae4edffdd6496d7131f".
● In the next request the header If-None-Match is sent with the ETag valuei.e: If-None-Match: "15f0fff99ed5aae4edffdd6496d7131f"
● If the ETag match, the server responds 304
![Page 45: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/45.jpg)
Tools● Most of browser tools has a network analyzer● The example below were made with Chrome dev tool
![Page 46: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/46.jpg)
Tips
● For static content: use Cache-Control.● Cache-Control is easy to check.● Avoid conditional Gets.● Use the app version or a fingerprint in the url.
![Page 47: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/47.jpg)
Tips
● For private content: use Cache-Control : private to avoid proxy caching.
● Prevent caching: use Cache-Control:no-cache, no-store.
● Urls with query string.
![Page 48: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/48.jpg)
Keep alive (reuse connections)
![Page 49: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/49.jpg)
● Client and server keep the connection open, unless the client indicates otherwise (via Connection: close header).
● Http connections are expensive.● Saves TCP handshake ( 150 ms average ).
![Page 50: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/50.jpg)
● Persistent connections send multiple request and response interactions over single connection.
● If the connection is not persistent you can specify a time out.
![Page 51: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/51.jpg)
Persisten connection
![Page 52: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/52.jpg)
Advantages
● CPU & memory savings, less tcp connections and fewer TCP control blocks.
● Allows request and response pipelining.● Reduce network load, less packets sent.● Supported by modern browsers.
![Page 53: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/53.jpg)
Parallel downloads
The biggest impact on end-user response times is the number of components in the page
![Page 54: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/54.jpg)
How it works?
● Images can be downloaded in parallel● JS and CSS..other story
![Page 55: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/55.jpg)
● Loading steps○ downloading (can be parallel )○ parsing○ executing
● Rules○ Scripts prevents other scripts to be downloaded
and parsed○ Stylessheets prevent scripts to be downloaded
and parsed○ Modern browsers start looking ahead in the
document and pre-loading stylesheets and scripts
![Page 56: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/56.jpg)
The HTTP/1.1 RFC
A single-user client SHOULD NOT maintain more than 2 connections with any server or proxy.
![Page 57: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/57.jpg)
The HTTP/1.1 RFC
A single-user client SHOULD NOT maintain more than 2 connections with any server or proxy.
![Page 58: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/58.jpg)
IE 6 and 7: 2IE 8: 6IE 9: 6IE 10: 8Firefox 2: 2Firefox 3: 6Firefox 4 to 17: 6Opera 9.63: 4Opera 10: 8Opera 11 and 12: 6Chrome 1 and 2: 6Chrome 3: 4Chrome 4 to 28: 6Safari 3 and 4: 4
How browsers handle it?
● Browsers don't have to follow this guideline.
● Parallel connections.
![Page 59: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/59.jpg)
Nice trick!
● The number of parallel connections applies to a server.
● Use multiple domain names○ i.e resources1.domain.com, resources2.
domain.com○ Expands per server connection limit.○ If the domains are CNAMEs of the same ip,
works too!
![Page 60: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/60.jpg)
Nice trick!
![Page 61: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/61.jpg)
Trade off
● DNS lookup ~ 150 ms● Browser cpu per parallel download● Bandwidth
![Page 62: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/62.jpg)
Reduce client request time by reducing the request size
Small request
![Page 63: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/63.jpg)
Objective
● Minimize the request overhead● Cut down on client request time by reducing the
number of bytes uploaded as request header data● Average request size is 1500 bytes.
![Page 64: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/64.jpg)
How
● Keeping cookies and request headers as small as possible ensures that an HTTP request can fit into a single packet.
● Small urls.● Small cookies.● Remove unused header.
![Page 65: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/65.jpg)
For static content
Cookieless domain
![Page 66: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/66.jpg)
Static content
● Objective:
○ If you set a cookie in particular domain, all subsequent HTTP requests for that domain must include the cookie.
○ Static content, such as images, JS and CSS files, don't need to be accompanied by cookies.
○ Avoid caching user info.
![Page 67: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/67.jpg)
Static content
● How:○ Create a domain for static content○ Use caching headers○ CDNs avoid cookies
![Page 68: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/68.jpg)
Use browser idle time
Prefetching
![Page 69: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/69.jpg)
Objective
● Use the browser idle time to download or prefetch documents that the user might visit in the near future.
![Page 70: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/70.jpg)
Which content prefetch?
● Images commonly used.● The next page of the search results.● Prefetch common DNS.
![Page 71: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/71.jpg)
● Image:
● Full page
● DNS
● Be aware of○ Bandwidth, website statistics
![Page 72: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/72.jpg)
Where and why
Javascript load & execution
![Page 73: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/73.jpg)
Where to load?
![Page 74: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/74.jpg)
Where and why?
● In the head: RUM, analytics● before </body>: scripts needed by page load● After page load: scripts needed soon after
page load● On demand: In reaction to users
![Page 75: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/75.jpg)
With and without blocking
Javascript loading
![Page 76: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/76.jpg)
Motivation
● Scripts blocks downloads and render.
![Page 77: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/77.jpg)
Several ways avoid it
● XHR Eval● XHR Injection● Script in Iframe● Script DOM Element● Script Defer
![Page 78: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/78.jpg)
Avoid blocking - Simple approach
![Page 79: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/79.jpg)
Avoid blocking - adding a callback
![Page 80: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/80.jpg)
Avoid blocking - adding a callback
![Page 81: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/81.jpg)
Avoid blocking - cross browser
![Page 82: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/82.jpg)
Avoid blocking - onload event● Blocks onload event until the script have been
downloaded and executed○ script defer○ script async○ script dom element
● Fix○ If you want to ensure that the JavaScript doesn't
start to download or execute until after the load event, you can insert it using the window.onload event handler:
![Page 83: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/83.jpg)
Avoid blocking - onload event
![Page 84: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/84.jpg)
Sometimes the image weight its 40-50% of the complete page weight
Image Optimization
![Page 85: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/85.jpg)
Lossless optimizations
● Are those that take an image and produce another image, which renders exactly the same and it's smaller in file size than the original
● The lossless file size savings come from:○ Using better compression algorithms to store the
pixel information.○ Removing unneeded metadata that goes with the
image file.
![Page 86: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/86.jpg)
GIF● The best way to optimize a GIF image is to convert it
to PNG8.● It can store up to 256 colors, just like GIF.● PNG8 supports alpha transparency.● Software:
○ Photoshop○ OptiPNG
● Animated GIF○ Don't convert to PNG○ Software:
■ GIFSicle
![Page 87: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/87.jpg)
JPEG
● Edit image metadata ○ Software: JPEGTran, EXIFTool
● Optimizing compression○ Software: JPEGTran
● Cropping○ Rotation to 90, 180, 270 degrees
![Page 88: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/88.jpg)
PNG
● Icons, illustrations and photos with high contrast.● Support transparency (alpha channel).● Optimizations
○ Strip PNG chunks○ Better pixel compression
● Software○ TinyPNG○ OptiPNG○ PNGOptimizer
![Page 89: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/89.jpg)
● Stoyan test over 1000 sites○ Convert GIFs to PNG ( -23% )○ PNG optimization tools ( -17% )○ Run JPEGTran on all JPEGs ( -13% )○ Optimize animations with GIFSicle ( -4% )
![Page 90: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/90.jpg)
JPEG ProgressivePerceived speed is more important that actual speed
![Page 91: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/91.jpg)
JPEG Progressive
● Two types of images, baseline and progressive● Baseline jpeg: is a full-resolution top-to-bottom scan
of the image
![Page 92: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/92.jpg)
JPEG Progressive
● Progressive jpeg: is a series of scans of increasing quality, loads from low quality to high in several "passes"
![Page 93: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/93.jpg)
JPEG Progressive
● The progressive jpeg’s first pass is low-resolution, but it contains as much information, or more, as the small image
● Software:○ jpegtran○ jpegcrop
● Images of file size 10K and over have a better chance of being smaller when using the progressive JPEG format
![Page 94: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/94.jpg)
WebPA new image format for the Web
![Page 95: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/95.jpg)
WebP
● What is? ○ is a new image format that provides lossless and
lossy compression for images on the web
● 26% smaller than PNG● 25-34% smaller than JPEG● Supports transparency ( alpha channel )
![Page 96: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/96.jpg)
WebP
● Software○ CwebP○ DwebP○ libwebp
● Support○ Chrome 9+○ Opera 12+○ Android 4+○ Opera mobile 11+○ Chrome for android 27+
![Page 97: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/97.jpg)
Muchas gracias!!!
![Page 98: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/98.jpg)
![Page 99: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/99.jpg)
Links
● http://www.rackaid.com/resources/time-to-first-byte/
● http://jackwhitey.hubpages.com/hub/cdn● https://developers.google.
com/speed/articles/gzip● https://devcenter.heroku.
com/articles/increasing-application-performance-with-http-cache-headers#http-cache-headers
● https://developers.google.com/speed/docs/best-practices/caching
![Page 100: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/100.jpg)
Links
● http://www.nczonline.net/blog/2009/06/23/loading-javascript-without-blocking/
● http://www.stevesouders.com/blog/2009/04/27/loading-scripts-without-blocking/
● http://www.stevesouders.com/blog/2008/12/27/coupling-async-scripts/
● http://calendar.perfplanet.com/2010/the-truth-about-non-blocking-javascript/
![Page 101: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/101.jpg)
Links
● http://www.igvita.com/2011/10/04/optimizing-http-keep-alive-and-pipelining/
● http://tools.ietf.org/id/draft-thomson-hybi-http-timeout-01.html#rfc.section.2
● http://www.dcs.bbk.ac.uk/~ptw/teaching/http/slide15.html
● http://www.dcs.bbk.ac.uk/~ptw/teaching/http/slide16.html
● http://abdussamad.com/archives/169-Apache-optimization:-KeepAlive-On-or-Off.html
![Page 102: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/102.jpg)
Links
● http://davidwalsh.name/javascript-domready● http://api.jquery.com/ready/● http://alexsexton.com/blog/2010/01/dont-let-
document-ready-slow-you-down/● https://developers.google.
com/speed/docs/best-practices/request● http://www.nczonline.
net/blog/2009/05/05/http-cookies-explained/
![Page 103: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/103.jpg)
Links
● http://www.catswhocode.com/blog/mastering-html5-prefetching
● http://davidwalsh.name/dns-prefetching● http://davidwalsh.name/html5-prefetch● http://statichtml.com/2011/link-prefetching-
broken-in-chrome.html● http://www.bookofspeed.com/chapter5.html● http://calendar.perfplanet.
com/2012/progressive-jpegs-a-new-best-practice/
![Page 104: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/104.jpg)
Links
● http://caniuse.com/webp● https://developers.google.com/speed/webp/?
hl=es-ES● http://news.cnet.com/8301-1023_3-
57585114-93/google-cuts-network-usage-by-terabytes-by-switching-to-webp/
● https://developers.google.com/speed/spdy/● http://www.chromium.org/spdy● http://googlecode.blogspot.com.
ar/2012/01/making-web-speedier-and-safer-with-spdy.html
● http://www.chromium.org/spdy
![Page 105: Web performance mercadolibre - ECI 2013](https://reader034.vdocuments.mx/reader034/viewer/2022042700/559470c21a28ab990e8b4712/html5/thumbnails/105.jpg)
Links
● http://dev.chromium.org/spdy/spdy-best-practices
● http://www.slideshare.net/nzakas/enough-withthejavascriptalready
● http://ejohn.org/blog/browser-page-load-performance/
● http://www.stevesouders.com/blog/2008/03/20/roundup-on-parallel-connections/
● http://www.yuiblog.com/blog/2007/04/11/performance-research-part-4/