SlideShare a Scribd company logo
Web Performance Optimization
Just one second please !
Maxime Lemaitre
• Introduction
• Goals & Objectives
• Why performance matters ?
• Web application delivery chain
• Some rules & Some tools
• Next Steps
2
Agenda
• Evangelize performance and explain why it is
important
– Have a performance culture !
– Have a performance plan !
• Do performance tests, setup production metrics
& KPIs, do monitoring and reports
• And of course, increase responsiveness of
your website !
3
Goals & Objectives
• We won’t talk (today) about
– Load Testing
– How to write efficient data acces queries
– Which is the fastest between C#, Java or Php ?
– ….
4
Web performance matters ?
short history : from a tech challenge to a differentiator
• First decade of the web's existence (1993 – 2003).
– Performance focus on :
• Optimize website code (simple scripts)
• Improve data access (use indexes, fewer queries, …)
• Reduce packet loss and retransmission
• Pushing hardware limitations (CPU, Memory, IO…)
 Not focused on browser display speed
• An emerging industry (2004-2009)
– Steve Souders (Yahoo), pioneer in « web performance optimization »
• 85% of the time that it takes to download and view a website is controlled by the front-end structure
• 10 predictions (fast by default, Visibility into the browser, monitoring, mobile, … => a differientator)
– Velocity 2009 Conference is a key event in web performance
• Many case studies from Microsoft, AOL, Amazon, ShopZilla , …
• Not only for techs but also other parts of the organization (management, marketing, sales, …)
• Last years (2010 – Now)
– Google : « we’ve decided to take site speed into account in our search rankings »
– For an ecommerce website, it’s been proven that speed = money
– Trend : make the web faster because web pages are bigger and more complex than ever
Bing : page that was 2 seconds slower resulted in a 4.3% drop in revenue/user
Yahoo : 400 milliseconds slowdown resulted in a 5-9% drop in full-page traffic
Google : 400 millisecond delay caused a 0.59% drop in searches/user
Even after the delay was removed, these users still had -0.21% fewer searches
 slower user experience affects long term behavior
AOL : page views drop off as page load times increase
Mozilla : Shaving 2.2 seconds off their home page increased downloads by 15.4%
ShopZilla : 5 second speed up
• 25% increase in page views
• 7-12% increase in revenue
• 50% reduction in hardware
Amazon : Every 100ms delay costs 1% of sales
5
Web performance matters ?
case studies in web industry
6
Why performance matters ?
for customers (source : Velocity Conf, Aberdeen, Gomez, Akamai)
Is Web Performance important for your company ?
• Are you in a competitive industry ?
• Do you sell something ?
• Does another website sell basically the « same
thing »
• Is is important to attract new users ?
• Is SEO important for you ?
• Does you marketing team wants to show
everything on your homepage ?
• ….
• Better user experience
– Customers will be happier and will tell others how good we are
– Keep them more focused on our content, rather than waiting for scripts/images
• Improve SEO
– One of the 200 signals used in Google Rankings
• Mobile performance : a new challenge
– Tablets/Smartphones are slower than desktops
– Much more limits and latency
• Improve conversion rate
– every second win, will boost customer confidence and trust in your site
• Reduce costs
– Bandwidth
– Less Hardware/Servers
• Better Scalability
7
Why performance matters ?
for techs & devs
• Final page speed is a depending on
– User computer and browser
– User current activity
– User network connection/ISP
– Internet Backbone
– Web Hosting location
– HTML (JS, CSS, Images, ..)
– Third-Party libraries / Ads / Analytics
– CDN
– Firewall/Load balancer
– Web Page / server code
– Frontend servers / Web Farms
– API/WebServices Calls
– Middle Tier / Backend servers
– Database
– …
8
Web Application Delivery Chain
performance at the bottom line
Do not trust that every user have a
Core i5 CPU with 8 Go Ram on
Windows 7 on a 100 Mbits/s
connection ! It’s false !
Try to test performance on slowest
computers and slowest bandwidth
80-90% of the end-user response time is spent on the frontend !
9
Web Performance
where to start ?
“We should forget about small efficiencies, say
about 97% of the time: premature optimization is
the root of all evil”
Donald Knuth
Never automatically apply tips, best
practices & improvements without
checking before/after the changes.
=> Profiling and Micro-Benchmark
10
Important Note
before going deeper
• Yslow & PageSpeed
– Proven front-end best practices & recommandations
– Very popular & easy to install (browser extension or online service)
– Current : Yslow (23 best practices) & PageSpeed (31 rules)
• But …
– does not look at our Infrastructure, Application Performance, CDN, DB Queries,
datacenter distribution, load balancing, …
– does not include the actual speed of the tested page !
– Lower scores/grades can load faster than Higher scores
11
Web Performance auditors
Google PageSpeed & YSlow
Html Parsing Pipeline
how page loads
• Loading a page is not as simple as
dowloading a single file
– Involve dynamic ressources
– Cascading stylesheet
– Javascripts
• Common performance issue :
Because JavaScript code can alter the content
and layout of a web page, the browser delays
rendering any content that follows a script tag
until that script has been downloaded, parsed and
executed.
Many browsers block the downloading of
resources referenced in the document after
scripts until those scripts are downloaded and
executed
12
Round-trip time (RTT) is the time it takes for a client to send a request and the
server to send a response over the network, not including the time required for
data transfer.
• Minimize redirects
• Use HTTP Cache Headers
• Avoid bad/duplicated/useless requests
• Combine external JavaScript & Css
• Combine images using CSS sprites
• Optimize the order of styles and scripts
• Prefer asynchronous resources (Async or Deferred JS)
• Parallelize downloads across hostnames
• …
13
Golden Rule #1
minimize round-trip times
Downloading 50 B always have a cost !
14
Less than 6 connections per hostname
Limit number of requests
Amount of data sent in each server response can add significant latency,
especially in areas where bandwidth is constrained
• Enable Gzip compression
• Limit HTTP Headers (Uncompressed)
• Remove unused CSS/JS/comments
• Avoid inline/embedded styles and scripts
• Minify CSS & JavaScript
• Minify HTML
• Optimize, Optimize, Optimize images
• Serve scaled images
• …
15
Golden Rule #2
Minimize Request Overhead & payload size
Web images take up the majority of the download time in most web pages
• Choose an appropriate file format (JPG, PNG, GIF)
– For JPG, use progressive image (demo)
• Optimize image size
– Crop whitespace, Remove useless data (color palette, EXIFF, ..)
– Apply a Lossless compressor (OptiPNG or PNGOUT)
• Try to apply width and height for each <img> tag
– Avoid unnecessary repaints and reflows during rendering
– But do not use it to scale images : server already scaled images
• Use Sprites (see )
– reduced the number of HTTP requests and avoided any potential delay
• Use Data-URI
– inline the content of the URI you would normally point to
16
Images Optimizations
Web images take up the majority of the download time in most web pages
Once resources have been downloaded to the client, the browser still needs to
load, interpret, and render HTML, CSS, and JavaScript code.
• Limit Number of DOM elements
• Defer loading of JavaScript and Third party components
• Avoid DOM alterations
• Styles at top, Scripts at bottom
• Use efficient CSS selectors & Avoid CSS expressions
• Specify image dimensions
• Specify a character set
• Check Javascript and especially Jquery performance
• …
Google SpeedTracer could help you (home)
low level instrumentation points inside Chrome
17
Golden Rule #3
Optimize Browser rendering
• Styles are downloaded and applied when rendering
Browsers block rendering a web page until all external stylesheets have been
downloaded
- Put styles in head allow the browser to progressively render the page
- Put styles in body can cause repaints & reflows (demo)
• Scripts are downloaded, parsed and executed
The page has to wait for the script blocks to be fully downloaded, parsed and
executed before being able to parse and render any following HTML
– Block the rendering of any following HTML
– Block the downloading of resources referenced in the document after the script
18
Quick Focus : Styles & Scripts
Why is it so important to optimize styles & scripts?
What is the page speed (with/without Cache) for this
ridicoulous page ?
19
Scripts
Stop paying the Script tax
• First View
• Repeat View
• Repeat View (on my laptop in power saving mode)
20
Scripts
Stop paying the Script tax²
Even from cache (no
download), it takes a
few ms to parse &
exec Scripts.
Not so fast …
Easy to write JavaScript …
…and easy to write really really bad JavaScript and slow down page load
• Minimal recommandations
– Always use the latest version of Jquery (test)
jQuery team is always looking to bring improvements
– Use appropriate selections (test)
Many ways to select an element, but they don’t have the same performance
Id < Tag < Class
– Do not repeat selectors & abuse chain
Cache results & object
– Use for instead of foreach (test)
Native JavaScript functions is always faster
– Do use Jquery … if possible (test)
Native JavaScript functions is always faster²
• Continue Reading here
21
Jquery Performance
with great power comes great responsibility (Spiderman)
22
How to mesure/improve performance ?
hopefully there are many tools !
• Sql Profiler
• Graphite
• Web Developpers
Tools
• WebPageTest.org
• PhantomJS
• Selenium Web Driver
• Har Viewer
• Google Page Speed
• Yslow
• dotTrace
• Pingdom tools
• Fiddler
• jsPerf
• MVC MiniProfiler
• dynaTrace
• Google Analytics
• IIS & Apache Logs
• Performance coutners
• Visual Studio Web
Perf
• Gtmetrix
• Micro Benchmark
• Google Site Speed
• Centreon
• New Relic
• Node.js
• DB Provider Client
Statistics
• SpeedTrace
• Headless Browsers
• Boomerang.js
• MVC Bundles
• Optipng
• Glimpse
• SpriteMe
• Firebug
• Your own tool here!
• Learn how to improve Web performance
• Investigate available performance tools
– Dev customs tools if necessary
• Automate performance testing
• …
It’s only the beginning !
PS : And of course, check Performance of your Web Site 
23
Next Steps
• https://developers.google.com/speed/
• http://developer.yahoo.com/performance/
• http://www.webpagetest.org/
• http://ie.microsoft.com/testdrive/HTML5/DOMContentLoaded/Default.html
• http://www.softwareishard.com/har/viewer/ (HAR file viewer)
• https://github.com/blog/1252-how-we-keep-github-fast (github performance)
• http://www.whatwg.org/specs/web-apps/current-
work/multipage/parsing.html#parsing (Parsing HTML Documents)
• http://www.stevesouders.com/blog/2010/05/07/wpo-web-performance-
optimization/ (must read)
• http://dmix.ca/2010/01/the-marketing-of-sports-betting-sites/ (betting
industry)
• http://sixrevisions.com/tools/8-excellent-tools-for-optimizing-your-images/
• http://www.browserscope.org
• http://browserdiet.com/
• http://gtmetrix.com/
24
Appendices
Yslow Best Practices
Add Expires headers
Avoid AlphaImageLoader filter
Avoid CSS expressions
Avoid empty src or href
Avoid HTTP 404 (Not Found) error
Avoid URL redirects
Compress components with gzip
Configure entity tags (ETags)
Do not scale images in HTML
Make AJAX cacheable
Make favicon small and cacheable
Make fewer HTTP requests
Make JavaScript and CSS external
Minify JavaScript and CSS
Put CSS at the top
Put JavaScript at bottom
Reduce cookie size
Reduce DNS lookups
Reduce the number of DOM elements
Remove duplicate JavaScript and CSS
Use a Content Delivery Network (CDN)
Use cookie-free domains
Use GET for AJAX requests
25
Avoid a character set in the meta tag
Avoid bad requests
Avoid CSS @import
Avoid CSS expressions (deprecated)
Avoid document.write
Avoid Flash on mobile webpages
Avoid landing page redirects
Combine external CSS
Combine external JavaScript
Combine images using CSS sprites
Defer loading of JavaScript
Defer parsing of JavaScript
Enable gzip compression
Enable Keep-Alive
Improve server response time
Inline small CSS
Inline small JavaScript
Leverage browser caching
Leverage proxy caching (deprecated)
Make landing page redirects cacheable
Minify CSS
Minify HTML
Minify JavaScript
Minimize cookie size (deprecated)
Minimize DNS lookups
Minimize redirects
Minimize request size
Optimize images
Optimize the order of styles and scripts
Parallelize downloads across hostnames
Prefer asynchronous resources
Put CSS in the document head
Remove query strings from static resources
Remove unused CSS
Serve resources from a consistent URL
Serve scaled images
Serve static content from a cookieless domain
Specify a cache validator
Specify a character set early
Specify a Vary: Accept-Encoding header
Specify a viewport for mobile browsers
Specify image dimensions
Use an application cache
Use efficient CSS selectors
26
PageSpeed Rules

More Related Content

PPTX
Mini-training: Personalization & Recommendation Demystified
PPTX
Wa mw 2013
PPTX
Level Up Web: Modern Web Development and Management Practices for Libraries
PPTX
LITA Forum 2012 Web Analytics Strategy Preconference
PPTX
LITA Forum 2012 Web Analytics Preconference
PDF
Webinar: Increase Conversion With Better Search
PDF
Talent Base: Best practises in a WCM project
PDF
Mini-Training: JS Graphical Libraries
Mini-training: Personalization & Recommendation Demystified
Wa mw 2013
Level Up Web: Modern Web Development and Management Practices for Libraries
LITA Forum 2012 Web Analytics Strategy Preconference
LITA Forum 2012 Web Analytics Preconference
Webinar: Increase Conversion With Better Search
Talent Base: Best practises in a WCM project
Mini-Training: JS Graphical Libraries

Similar to Web Performance Optimization (WPO) (20)

PPTX
Website Performance
PPTX
Performance Tuning Web Apps - The Need For Speed
PDF
High Performance Websites
PPTX
10 things you can do to speed up your web app today stir trek edition
PPTX
Web Page Speed - A Most Important Feature
PPTX
Why your slow loading website is costing you sales and how to fix it
PPTX
Why your slow loading website is costing you sales and how to fix it
PDF
Web Performance in the Age of HTTP2 - Topconf Tallinn 2016 - Holger Bartel
PPTX
Web Performance 101
PDF
Tips tricks deliver_high_performing_secure_web_pages
PPTX
Optimizing website performance
PDF
Mobile web performance dwx13
PPTX
High Performance Web/Mobile Pages - Automation
PPTX
Leveraging Website Speed to Increase Sales
PPTX
Design Camp Boston - Designing Faster Websites
PPTX
Breaking the Speed Limit: Faster Websites Win
PPTX
Performace optimization (increase website speed)
PPTX
Sava Sertov - Performance specialist, eCommera: site performance - slow, fast...
PDF
Business Aspects of High Performance Websites
PPT
Web performance Talk
Website Performance
Performance Tuning Web Apps - The Need For Speed
High Performance Websites
10 things you can do to speed up your web app today stir trek edition
Web Page Speed - A Most Important Feature
Why your slow loading website is costing you sales and how to fix it
Why your slow loading website is costing you sales and how to fix it
Web Performance in the Age of HTTP2 - Topconf Tallinn 2016 - Holger Bartel
Web Performance 101
Tips tricks deliver_high_performing_secure_web_pages
Optimizing website performance
Mobile web performance dwx13
High Performance Web/Mobile Pages - Automation
Leveraging Website Speed to Increase Sales
Design Camp Boston - Designing Faster Websites
Breaking the Speed Limit: Faster Websites Win
Performace optimization (increase website speed)
Sava Sertov - Performance specialist, eCommera: site performance - slow, fast...
Business Aspects of High Performance Websites
Web performance Talk
Ad

More from Betclic Everest Group Tech Team (20)

PPTX
Mini training - Reactive Extensions (Rx)
PPTX
Mini training - Moving to xUnit.net
PPTX
Mini training - Introduction to Microsoft Azure Storage
PPTX
Mini training- Scenario Driven Design
PDF
Email Management in Outlook
PDF
Mini-Training: SSO with Windows Identity Foundation
PPTX
Training - What is Performance ?
PPTX
Mini-Training: Docker
PDF
Mini Training Flyway
PDF
Mini-Training: NDepend
PDF
Management 3.0 Workout
PDF
PPTX
Short-Training asp.net vNext
PPTX
Training – Going Async
PDF
Mini-Training: Mobile UX Trends
PPTX
Training: MVVM Pattern
PPTX
Mini-training: Let’s Git It!
PDF
AngularJS Best Practices
PDF
Mini-Training: Roslyn
Mini training - Reactive Extensions (Rx)
Mini training - Moving to xUnit.net
Mini training - Introduction to Microsoft Azure Storage
Mini training- Scenario Driven Design
Email Management in Outlook
Mini-Training: SSO with Windows Identity Foundation
Training - What is Performance ?
Mini-Training: Docker
Mini Training Flyway
Mini-Training: NDepend
Management 3.0 Workout
Short-Training asp.net vNext
Training – Going Async
Mini-Training: Mobile UX Trends
Training: MVVM Pattern
Mini-training: Let’s Git It!
AngularJS Best Practices
Mini-Training: Roslyn
Ad

Recently uploaded (20)

PDF
Encapsulation theory and applications.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Modernizing your data center with Dell and AMD
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Electronic commerce courselecture one. Pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
KodekX | Application Modernization Development
PDF
Approach and Philosophy of On baking technology
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Cloud computing and distributed systems.
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Encapsulation theory and applications.pdf
Understanding_Digital_Forensics_Presentation.pptx
NewMind AI Monthly Chronicles - July 2025
Modernizing your data center with Dell and AMD
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Digital-Transformation-Roadmap-for-Companies.pptx
Network Security Unit 5.pdf for BCA BBA.
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Spectral efficient network and resource selection model in 5G networks
Electronic commerce courselecture one. Pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Encapsulation_ Review paper, used for researhc scholars
KodekX | Application Modernization Development
Approach and Philosophy of On baking technology
Chapter 3 Spatial Domain Image Processing.pdf
Cloud computing and distributed systems.
Bridging biosciences and deep learning for revolutionary discoveries: a compr...

Web Performance Optimization (WPO)

  • 1. Web Performance Optimization Just one second please ! Maxime Lemaitre
  • 2. • Introduction • Goals & Objectives • Why performance matters ? • Web application delivery chain • Some rules & Some tools • Next Steps 2 Agenda
  • 3. • Evangelize performance and explain why it is important – Have a performance culture ! – Have a performance plan ! • Do performance tests, setup production metrics & KPIs, do monitoring and reports • And of course, increase responsiveness of your website ! 3 Goals & Objectives • We won’t talk (today) about – Load Testing – How to write efficient data acces queries – Which is the fastest between C#, Java or Php ? – ….
  • 4. 4 Web performance matters ? short history : from a tech challenge to a differentiator • First decade of the web's existence (1993 – 2003). – Performance focus on : • Optimize website code (simple scripts) • Improve data access (use indexes, fewer queries, …) • Reduce packet loss and retransmission • Pushing hardware limitations (CPU, Memory, IO…)  Not focused on browser display speed • An emerging industry (2004-2009) – Steve Souders (Yahoo), pioneer in « web performance optimization » • 85% of the time that it takes to download and view a website is controlled by the front-end structure • 10 predictions (fast by default, Visibility into the browser, monitoring, mobile, … => a differientator) – Velocity 2009 Conference is a key event in web performance • Many case studies from Microsoft, AOL, Amazon, ShopZilla , … • Not only for techs but also other parts of the organization (management, marketing, sales, …) • Last years (2010 – Now) – Google : « we’ve decided to take site speed into account in our search rankings » – For an ecommerce website, it’s been proven that speed = money – Trend : make the web faster because web pages are bigger and more complex than ever
  • 5. Bing : page that was 2 seconds slower resulted in a 4.3% drop in revenue/user Yahoo : 400 milliseconds slowdown resulted in a 5-9% drop in full-page traffic Google : 400 millisecond delay caused a 0.59% drop in searches/user Even after the delay was removed, these users still had -0.21% fewer searches  slower user experience affects long term behavior AOL : page views drop off as page load times increase Mozilla : Shaving 2.2 seconds off their home page increased downloads by 15.4% ShopZilla : 5 second speed up • 25% increase in page views • 7-12% increase in revenue • 50% reduction in hardware Amazon : Every 100ms delay costs 1% of sales 5 Web performance matters ? case studies in web industry
  • 6. 6 Why performance matters ? for customers (source : Velocity Conf, Aberdeen, Gomez, Akamai) Is Web Performance important for your company ? • Are you in a competitive industry ? • Do you sell something ? • Does another website sell basically the « same thing » • Is is important to attract new users ? • Is SEO important for you ? • Does you marketing team wants to show everything on your homepage ? • ….
  • 7. • Better user experience – Customers will be happier and will tell others how good we are – Keep them more focused on our content, rather than waiting for scripts/images • Improve SEO – One of the 200 signals used in Google Rankings • Mobile performance : a new challenge – Tablets/Smartphones are slower than desktops – Much more limits and latency • Improve conversion rate – every second win, will boost customer confidence and trust in your site • Reduce costs – Bandwidth – Less Hardware/Servers • Better Scalability 7 Why performance matters ? for techs & devs
  • 8. • Final page speed is a depending on – User computer and browser – User current activity – User network connection/ISP – Internet Backbone – Web Hosting location – HTML (JS, CSS, Images, ..) – Third-Party libraries / Ads / Analytics – CDN – Firewall/Load balancer – Web Page / server code – Frontend servers / Web Farms – API/WebServices Calls – Middle Tier / Backend servers – Database – … 8 Web Application Delivery Chain performance at the bottom line Do not trust that every user have a Core i5 CPU with 8 Go Ram on Windows 7 on a 100 Mbits/s connection ! It’s false ! Try to test performance on slowest computers and slowest bandwidth
  • 9. 80-90% of the end-user response time is spent on the frontend ! 9 Web Performance where to start ?
  • 10. “We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil” Donald Knuth Never automatically apply tips, best practices & improvements without checking before/after the changes. => Profiling and Micro-Benchmark 10 Important Note before going deeper
  • 11. • Yslow & PageSpeed – Proven front-end best practices & recommandations – Very popular & easy to install (browser extension or online service) – Current : Yslow (23 best practices) & PageSpeed (31 rules) • But … – does not look at our Infrastructure, Application Performance, CDN, DB Queries, datacenter distribution, load balancing, … – does not include the actual speed of the tested page ! – Lower scores/grades can load faster than Higher scores 11 Web Performance auditors Google PageSpeed & YSlow
  • 12. Html Parsing Pipeline how page loads • Loading a page is not as simple as dowloading a single file – Involve dynamic ressources – Cascading stylesheet – Javascripts • Common performance issue : Because JavaScript code can alter the content and layout of a web page, the browser delays rendering any content that follows a script tag until that script has been downloaded, parsed and executed. Many browsers block the downloading of resources referenced in the document after scripts until those scripts are downloaded and executed 12
  • 13. Round-trip time (RTT) is the time it takes for a client to send a request and the server to send a response over the network, not including the time required for data transfer. • Minimize redirects • Use HTTP Cache Headers • Avoid bad/duplicated/useless requests • Combine external JavaScript & Css • Combine images using CSS sprites • Optimize the order of styles and scripts • Prefer asynchronous resources (Async or Deferred JS) • Parallelize downloads across hostnames • … 13 Golden Rule #1 minimize round-trip times Downloading 50 B always have a cost !
  • 14. 14 Less than 6 connections per hostname Limit number of requests
  • 15. Amount of data sent in each server response can add significant latency, especially in areas where bandwidth is constrained • Enable Gzip compression • Limit HTTP Headers (Uncompressed) • Remove unused CSS/JS/comments • Avoid inline/embedded styles and scripts • Minify CSS & JavaScript • Minify HTML • Optimize, Optimize, Optimize images • Serve scaled images • … 15 Golden Rule #2 Minimize Request Overhead & payload size
  • 16. Web images take up the majority of the download time in most web pages • Choose an appropriate file format (JPG, PNG, GIF) – For JPG, use progressive image (demo) • Optimize image size – Crop whitespace, Remove useless data (color palette, EXIFF, ..) – Apply a Lossless compressor (OptiPNG or PNGOUT) • Try to apply width and height for each <img> tag – Avoid unnecessary repaints and reflows during rendering – But do not use it to scale images : server already scaled images • Use Sprites (see ) – reduced the number of HTTP requests and avoided any potential delay • Use Data-URI – inline the content of the URI you would normally point to 16 Images Optimizations Web images take up the majority of the download time in most web pages
  • 17. Once resources have been downloaded to the client, the browser still needs to load, interpret, and render HTML, CSS, and JavaScript code. • Limit Number of DOM elements • Defer loading of JavaScript and Third party components • Avoid DOM alterations • Styles at top, Scripts at bottom • Use efficient CSS selectors & Avoid CSS expressions • Specify image dimensions • Specify a character set • Check Javascript and especially Jquery performance • … Google SpeedTracer could help you (home) low level instrumentation points inside Chrome 17 Golden Rule #3 Optimize Browser rendering
  • 18. • Styles are downloaded and applied when rendering Browsers block rendering a web page until all external stylesheets have been downloaded - Put styles in head allow the browser to progressively render the page - Put styles in body can cause repaints & reflows (demo) • Scripts are downloaded, parsed and executed The page has to wait for the script blocks to be fully downloaded, parsed and executed before being able to parse and render any following HTML – Block the rendering of any following HTML – Block the downloading of resources referenced in the document after the script 18 Quick Focus : Styles & Scripts Why is it so important to optimize styles & scripts?
  • 19. What is the page speed (with/without Cache) for this ridicoulous page ? 19 Scripts Stop paying the Script tax
  • 20. • First View • Repeat View • Repeat View (on my laptop in power saving mode) 20 Scripts Stop paying the Script tax² Even from cache (no download), it takes a few ms to parse & exec Scripts. Not so fast …
  • 21. Easy to write JavaScript … …and easy to write really really bad JavaScript and slow down page load • Minimal recommandations – Always use the latest version of Jquery (test) jQuery team is always looking to bring improvements – Use appropriate selections (test) Many ways to select an element, but they don’t have the same performance Id < Tag < Class – Do not repeat selectors & abuse chain Cache results & object – Use for instead of foreach (test) Native JavaScript functions is always faster – Do use Jquery … if possible (test) Native JavaScript functions is always faster² • Continue Reading here 21 Jquery Performance with great power comes great responsibility (Spiderman)
  • 22. 22 How to mesure/improve performance ? hopefully there are many tools ! • Sql Profiler • Graphite • Web Developpers Tools • WebPageTest.org • PhantomJS • Selenium Web Driver • Har Viewer • Google Page Speed • Yslow • dotTrace • Pingdom tools • Fiddler • jsPerf • MVC MiniProfiler • dynaTrace • Google Analytics • IIS & Apache Logs • Performance coutners • Visual Studio Web Perf • Gtmetrix • Micro Benchmark • Google Site Speed • Centreon • New Relic • Node.js • DB Provider Client Statistics • SpeedTrace • Headless Browsers • Boomerang.js • MVC Bundles • Optipng • Glimpse • SpriteMe • Firebug • Your own tool here!
  • 23. • Learn how to improve Web performance • Investigate available performance tools – Dev customs tools if necessary • Automate performance testing • … It’s only the beginning ! PS : And of course, check Performance of your Web Site  23 Next Steps
  • 24. • https://developers.google.com/speed/ • http://developer.yahoo.com/performance/ • http://www.webpagetest.org/ • http://ie.microsoft.com/testdrive/HTML5/DOMContentLoaded/Default.html • http://www.softwareishard.com/har/viewer/ (HAR file viewer) • https://github.com/blog/1252-how-we-keep-github-fast (github performance) • http://www.whatwg.org/specs/web-apps/current- work/multipage/parsing.html#parsing (Parsing HTML Documents) • http://www.stevesouders.com/blog/2010/05/07/wpo-web-performance- optimization/ (must read) • http://dmix.ca/2010/01/the-marketing-of-sports-betting-sites/ (betting industry) • http://sixrevisions.com/tools/8-excellent-tools-for-optimizing-your-images/ • http://www.browserscope.org • http://browserdiet.com/ • http://gtmetrix.com/ 24 Appendices
  • 25. Yslow Best Practices Add Expires headers Avoid AlphaImageLoader filter Avoid CSS expressions Avoid empty src or href Avoid HTTP 404 (Not Found) error Avoid URL redirects Compress components with gzip Configure entity tags (ETags) Do not scale images in HTML Make AJAX cacheable Make favicon small and cacheable Make fewer HTTP requests Make JavaScript and CSS external Minify JavaScript and CSS Put CSS at the top Put JavaScript at bottom Reduce cookie size Reduce DNS lookups Reduce the number of DOM elements Remove duplicate JavaScript and CSS Use a Content Delivery Network (CDN) Use cookie-free domains Use GET for AJAX requests 25
  • 26. Avoid a character set in the meta tag Avoid bad requests Avoid CSS @import Avoid CSS expressions (deprecated) Avoid document.write Avoid Flash on mobile webpages Avoid landing page redirects Combine external CSS Combine external JavaScript Combine images using CSS sprites Defer loading of JavaScript Defer parsing of JavaScript Enable gzip compression Enable Keep-Alive Improve server response time Inline small CSS Inline small JavaScript Leverage browser caching Leverage proxy caching (deprecated) Make landing page redirects cacheable Minify CSS Minify HTML Minify JavaScript Minimize cookie size (deprecated) Minimize DNS lookups Minimize redirects Minimize request size Optimize images Optimize the order of styles and scripts Parallelize downloads across hostnames Prefer asynchronous resources Put CSS in the document head Remove query strings from static resources Remove unused CSS Serve resources from a consistent URL Serve scaled images Serve static content from a cookieless domain Specify a cache validator Specify a character set early Specify a Vary: Accept-Encoding header Specify a viewport for mobile browsers Specify image dimensions Use an application cache Use efficient CSS selectors 26 PageSpeed Rules