SlideShare a Scribd company logo
Going on an HTTP Diet: Front-End Web Performance
"Never
underestimate the
        — CEO Eric Schmidt announcing
        Google Instant in September 2010
Going on an HTTP Diet: Front-End Web Performance
Going on an HTTP Diet: Front-End Web Performance
Going on an HTTP Diet: Front-End Web Performance
The Low-Hanging
      Fruit
    The 20 / 80 rule
I. Serve up lighter files

II. Trim back on HTTP

III. Keep things a-movin’
    (avoid blocking)
SERVE UP
Lighter Files
The HTTP Waterfall
Image Optimization
Images are often >50% of a page’s total weight!
Leaner JPEGs
Leaner JPEGs:
   Quality
Leaner JPEGs:
 Progressive
Leaner JPEGs:
  Metadata
Leaner JPEGs:
     Metadata
     command line ahoy!



> jpegtran -copy none -optimize
        src.jpg dest.jpg
Professional PNGs
Professional PNGs:
     bit depth
Professional PNGs:
       8bit
Professional PNGs:
 8bit alpha woes?
•8bit PNGs CAN have full alpha
 support!

•Use Adobe Fireworks instead
•Or run them through pngquant
Professional PNGs:
   PNGQUANT
     command line ahoy!




  > pngquant 256 whatever.png
Professional PNGs:
    PNGCRUSH
     command line ahoy!



 > pngcrush -rem alla -reduce
  -brute source.png dest.png
smush.it
That’s the URL!
animated GIFs are
      back
    gifsicle can help
Slimmer Text Fil
                         The Rudimentary Approach


•   class=“whatever”
    → class=whatever

•   http://www.utexas.edu/law/whatever.html
    → /law/whatever.html

•   <script type=“text/javascript”>
    → <script>

•   Use CSS shorthand!
Slimmer Text Fil
                  Minify your scripts and other text




jquery-1.6.3.js                          jquery-1.6.3.min.js
Slimmer Text Fil
            Minify your scripts and other text



• YUICompressor
• Google's Closure Compiler
• Dojo ShrinkSafe
• Packer
• JSMin
Slimmer Text Fil
                       Serious bandwidth savings with gzip


For Apache 2.x*:
<ifModule mod_deflate.c>

    AddOutputFilterByType DEFLATE text/html text/css application/x-javascript

</ifModule>




                                          * Note: don’t do this on Web Central…
Trim Back on
HTTP Requests
The Problem with
 HTTP Requests
 HTTP/1.1 specifies 2 maximum
 simultaneous TCP connections




    Source: HTTP/1.1 specification, RFC 2616 8.1.4
    http://www.w3.org/Protocols/rfc2616/rfc2616-
    sec8.html#sec8
The Problem with
 HTTP Requests
 HTTP/1.1 specifies 2 maximum
 simultaneous TCP connections

         (per domain)


    Source: HTTP/1.1 specification, RFC 2616 8.1.4
    http://www.w3.org/Protocols/rfc2616/rfc2616-
    sec8.html#sec8
HTTP Waterfall
     IE7




generated with http://
www.webpagetest.org/
HTTP Waterfall -
  Chrome 14
Remove Duplicates
                &
Fold print and
media query styles
Fold print and
   media query styles
<link rel="stylesheet" href="styles.css" />
<link rel="stylesheet" href="print.css" />
Fold print and
media query styles
/* Print styles in styles.css
@media print {
    body {
        background: #fff;
    }
}
CSS Image Sprites
CSS Image Sprites
use




      PS: Maybe use CSS opacity
      to cut down on the number
      of button states in an image
      sprite?
Data URIs
background-image: url("data:image/png;base64,xKfsiO…ssseAdd==");
Data URIs
Data URIs
•   Prevents the opening of an additional TCP request
Data URIs
•   Prevents the opening of an additional TCP request

•   Faster download than a separate image request
Data URIs
•   Prevents the opening of an additional TCP request

•   Faster download than a separate image request

•   Can be created on the fly in PHP with
    base64_encode()
Data URIs
•   Prevents the opening of an additional TCP request

•   Faster download than a separate image request

•   Can be created on the fly in PHP with
    base64_encode()

•   Are only cached if included inside of a stylesheet
    (not inline)
Data URIs
•   Prevents the opening of an additional TCP request

•   Faster download than a separate image request

•   Can be created on the fly in PHP with
    base64_encode()

•   Are only cached if included inside of a stylesheet
    (not inline)

•   ~30% larger than “real” image files
    (~2% if gzip is enabled)
Data URIs
•   Prevents the opening of an additional TCP request

•   Faster download than a separate image request

•   Can be created on the fly in PHP with
    base64_encode()

•   Are only cached if included inside of a stylesheet
    (not inline)

•   ~30% larger than “real” image files
    (~2% if gzip is enabled)

•   Wide browser support, but no IE 7 or older
    (and IE8 only supports up to 32KB of data)
Cache: Far-Future
    Expires
Cache: Far-Future
    Expires
Cache: Far-Future
        Expires
          Stick this in your .htaccess


<IfModule mod_expires.c>
ExpiresActive on
	 <FilesMatch ".(gif|jpg|png|js|css)$">
	    ExpiresDefault "access plus 5 years"
	 </FilesMatch>
</IfModule>
Cache: Far-Future
    Expires
Wait, why are they still seeing that version?!
Cache: Far-Future
         Expires
      Wait, why are they still seeing that version?!


• A good practice, but users might end up with old
  versions of styles and scripts…
Cache: Far-Future
         Expires
      Wait, why are they still seeing that version?!


• A good practice, but users might end up with old
  versions of styles and scripts…

• To force a fresh download you can rename the file
  (I hope you’ve got a CMS or build process that
   makes this easy!)
Cache: ETags
Cache: Disable
    ETags
 Another one for your .htaccess



 FileETag none
Cache: Disable
    ETags
 Another one for your .htaccess



 FileETag none


               Recommended by Microsoft and
               Apache!
               http://support.microsoft.com/?
               id=922733
               http://www.apacheweek.com/issues/
               02-0-18
Stay in Motion
(avoid resource
 blocking)
Blocking (IE7
  example)
What can cause
  blocking?
What can cause
           blocking? in
•   External scripts cause blocking,
    case of a document.write() and to
    ensure proper order of execution
What can cause
           blocking? in
•   External scripts cause blocking,
    case of a document.write() and to
    ensure proper order of execution

•Inline <script> can hang things up
What can cause
           blocking? in
•   External scripts cause blocking,
    case of a document.write() and to
    ensure proper order of execution

•Inline <script> can hang things up
•Scripts often don’t execute until
    stylesheets are finished downloading
What can cause
           blocking? in
•   External scripts cause blocking,
    case of a document.write() and to
    ensure proper order of execution

•Inline <script> can hang things up
•Scripts often don’t execute until
    stylesheets are finished downloading

•CSS @import causes blocking
    in older IE
What can cause
           blocking? in
•   External scripts cause blocking,
    case of a document.write() and to
    ensure proper order of execution

•Inline <script> can hang things up
•Scripts often don’t execute until
    stylesheets are finished downloading

•CSS @import causes blocking
    in older IE

•iframes can block onload from firing
Cuzillion
http://stevesouders.com/cuzillion/
How do we get
 around this?
How do we get
      around this?
•   Put stylesheets in the <head> using a
    <link> tag instead of @import
How do we get
      around this?
•   Put stylesheets in the <head> using a
    <link> tag instead of @import

•   Put your scripts as close to the
    </body> tag as possible (in most
    circumstances)
How do we get
      around this?
•   Put stylesheets in the <head> using a
    <link> tag instead of @import

•   Put your scripts as close to the
    </body> tag as possible (in most
    circumstances)

•   Use a script loader like LabJS or HeadJS
How do we get
      around this?
•   Put stylesheets in the <head> using a
    <link> tag instead of @import

•   Put your scripts as close to the
    </body> tag as possible (in most
    circumstances)

•   Use a script loader like LabJS or HeadJS

•   Use non-blocking script insertion
    techniques like XHR Injection **
Asynchronous
        Script Insertion
(function () {
    var ga   = document.createElement('script'),

        s     = document.getElementsByTagName('script')[0];

    ga.type   = 'text/javascript';
    ga.async = true;

    ga.src    = ('https:' === document.location.protocol ?
                'https://ssl' :
                'http://www') +
                '.google-analytics.com/ga.js';

    s.parentNode.insertBefore(ga, s);

}());
Forward-looking
  approaches
Forward-looking
     approaches
• <script  defer>
 (wide browser support, but
  execution order?)
Forward-looking
     approaches
• <script  defer>
 (wide browser support, but
  execution order?)

• <script async>
 (HTML5, widening support, but no IE)
Forward-looking
     approaches
• <script  defer>
 (wide browser support, but
  execution order?)

• <script async>
 (HTML5, widening support, but no IE)

• Web Workers
 (Multi-threaded JS processing! But no IE…)
DEMO

YSlow   PageSpeed
Going on an HTTP Diet: Front-End Web Performance
Ad

More Related Content

What's hot (20)

The Need for Speed - SMX Sydney 2013
The Need for Speed - SMX Sydney 2013The Need for Speed - SMX Sydney 2013
The Need for Speed - SMX Sydney 2013
Bastian Grimm
 
HTML5 Real-Time and Connectivity
HTML5 Real-Time and ConnectivityHTML5 Real-Time and Connectivity
HTML5 Real-Time and Connectivity
Peter Lubbers
 
A Forgotten HTTP Invisibility Cloak
A Forgotten HTTP Invisibility CloakA Forgotten HTTP Invisibility Cloak
A Forgotten HTTP Invisibility Cloak
Soroush Dalili
 
Flash And Dom
Flash And DomFlash And Dom
Flash And Dom
Mike Wilcox
 
ClubAJAX Basics - Server Communication
ClubAJAX Basics - Server CommunicationClubAJAX Basics - Server Communication
ClubAJAX Basics - Server Communication
Mike Wilcox
 
Nuts and Bolts of WebSocket Devoxx 2014
Nuts and Bolts of WebSocket Devoxx 2014Nuts and Bolts of WebSocket Devoxx 2014
Nuts and Bolts of WebSocket Devoxx 2014
Arun Gupta
 
Minimize website page loading time – 20+ advanced SEO tips
Minimize website page loading time – 20+ advanced SEO tipsMinimize website page loading time – 20+ advanced SEO tips
Minimize website page loading time – 20+ advanced SEO tips
CgColors
 
HTML5 vs Silverlight
HTML5 vs SilverlightHTML5 vs Silverlight
HTML5 vs Silverlight
Matt Casto
 
Rails security: above and beyond the defaults
Rails security: above and beyond the defaultsRails security: above and beyond the defaults
Rails security: above and beyond the defaults
Matias Korhonen
 
Re-thinking Performance tuning with HTTP2
Re-thinking Performance tuning with HTTP2Re-thinking Performance tuning with HTTP2
Re-thinking Performance tuning with HTTP2
Vinci Rufus
 
Search in WordPress - how it works and howto customize it
Search in WordPress - how it works and howto customize itSearch in WordPress - how it works and howto customize it
Search in WordPress - how it works and howto customize it
Otto Kekäläinen
 
High Performance WordPress
High Performance WordPressHigh Performance WordPress
High Performance WordPress
vnsavage
 
cache concepts and varnish-cache
cache concepts and varnish-cachecache concepts and varnish-cache
cache concepts and varnish-cache
Marc Cortinas Val
 
Profiling php applications
Profiling php applicationsProfiling php applications
Profiling php applications
Justin Carmony
 
Blazing Data With Redis (and LEGOS!)
Blazing Data With Redis (and LEGOS!)Blazing Data With Redis (and LEGOS!)
Blazing Data With Redis (and LEGOS!)
Justin Carmony
 
Connecting to Web Services on Android
Connecting to Web Services on AndroidConnecting to Web Services on Android
Connecting to Web Services on Android
sullis
 
WordPress security for everyone
WordPress security for everyoneWordPress security for everyone
WordPress security for everyone
Vladimír Smitka
 
Scaling Django
Scaling DjangoScaling Django
Scaling Django
Mike Malone
 
Racing The Web - Hackfest 2016
Racing The Web - Hackfest 2016Racing The Web - Hackfest 2016
Racing The Web - Hackfest 2016
Aaron Hnatiw
 
Happy Browser, Happy User! WordSesh 2019
Happy Browser, Happy User! WordSesh 2019Happy Browser, Happy User! WordSesh 2019
Happy Browser, Happy User! WordSesh 2019
Katie Sylor-Miller
 
The Need for Speed - SMX Sydney 2013
The Need for Speed - SMX Sydney 2013The Need for Speed - SMX Sydney 2013
The Need for Speed - SMX Sydney 2013
Bastian Grimm
 
HTML5 Real-Time and Connectivity
HTML5 Real-Time and ConnectivityHTML5 Real-Time and Connectivity
HTML5 Real-Time and Connectivity
Peter Lubbers
 
A Forgotten HTTP Invisibility Cloak
A Forgotten HTTP Invisibility CloakA Forgotten HTTP Invisibility Cloak
A Forgotten HTTP Invisibility Cloak
Soroush Dalili
 
ClubAJAX Basics - Server Communication
ClubAJAX Basics - Server CommunicationClubAJAX Basics - Server Communication
ClubAJAX Basics - Server Communication
Mike Wilcox
 
Nuts and Bolts of WebSocket Devoxx 2014
Nuts and Bolts of WebSocket Devoxx 2014Nuts and Bolts of WebSocket Devoxx 2014
Nuts and Bolts of WebSocket Devoxx 2014
Arun Gupta
 
Minimize website page loading time – 20+ advanced SEO tips
Minimize website page loading time – 20+ advanced SEO tipsMinimize website page loading time – 20+ advanced SEO tips
Minimize website page loading time – 20+ advanced SEO tips
CgColors
 
HTML5 vs Silverlight
HTML5 vs SilverlightHTML5 vs Silverlight
HTML5 vs Silverlight
Matt Casto
 
Rails security: above and beyond the defaults
Rails security: above and beyond the defaultsRails security: above and beyond the defaults
Rails security: above and beyond the defaults
Matias Korhonen
 
Re-thinking Performance tuning with HTTP2
Re-thinking Performance tuning with HTTP2Re-thinking Performance tuning with HTTP2
Re-thinking Performance tuning with HTTP2
Vinci Rufus
 
Search in WordPress - how it works and howto customize it
Search in WordPress - how it works and howto customize itSearch in WordPress - how it works and howto customize it
Search in WordPress - how it works and howto customize it
Otto Kekäläinen
 
High Performance WordPress
High Performance WordPressHigh Performance WordPress
High Performance WordPress
vnsavage
 
cache concepts and varnish-cache
cache concepts and varnish-cachecache concepts and varnish-cache
cache concepts and varnish-cache
Marc Cortinas Val
 
Profiling php applications
Profiling php applicationsProfiling php applications
Profiling php applications
Justin Carmony
 
Blazing Data With Redis (and LEGOS!)
Blazing Data With Redis (and LEGOS!)Blazing Data With Redis (and LEGOS!)
Blazing Data With Redis (and LEGOS!)
Justin Carmony
 
Connecting to Web Services on Android
Connecting to Web Services on AndroidConnecting to Web Services on Android
Connecting to Web Services on Android
sullis
 
WordPress security for everyone
WordPress security for everyoneWordPress security for everyone
WordPress security for everyone
Vladimír Smitka
 
Racing The Web - Hackfest 2016
Racing The Web - Hackfest 2016Racing The Web - Hackfest 2016
Racing The Web - Hackfest 2016
Aaron Hnatiw
 
Happy Browser, Happy User! WordSesh 2019
Happy Browser, Happy User! WordSesh 2019Happy Browser, Happy User! WordSesh 2019
Happy Browser, Happy User! WordSesh 2019
Katie Sylor-Miller
 

Viewers also liked (20)

生命經驗傳承 人生經驗比賽
生命經驗傳承 人生經驗比賽生命經驗傳承 人生經驗比賽
生命經驗傳承 人生經驗比賽
edwardshen
 
Winning Customers
Winning CustomersWinning Customers
Winning Customers
Violeta Salas
 
Apples’ iPhone, iPod touch and iPad Application Programming - CLASS 1
Apples’ iPhone, iPod touch and iPad Application Programming - CLASS 1Apples’ iPhone, iPod touch and iPad Application Programming - CLASS 1
Apples’ iPhone, iPod touch and iPad Application Programming - CLASS 1
Violeta Salas
 
Mobile Marketing and Social Campaigns
Mobile Marketing and Social CampaignsMobile Marketing and Social Campaigns
Mobile Marketing and Social Campaigns
Violeta Salas
 
Class 02 Objective C
Class 02   Objective CClass 02   Objective C
Class 02 Objective C
Violeta Salas
 
Find your true passion and do what you love to do
Find your true passion and do what you love to doFind your true passion and do what you love to do
Find your true passion and do what you love to do
Violeta Salas
 
Self discipline - Brian Tracy
Self discipline - Brian TracySelf discipline - Brian Tracy
Self discipline - Brian Tracy
Violeta Salas
 
стратегии международной рекламы
стратегии международной рекламыстратегии международной рекламы
стратегии международной рекламы
dutik
 
Mobile marketing & Business
Mobile marketing & Business Mobile marketing & Business
Mobile marketing & Business
Violeta Salas
 
Concerto Omaggio A Beatrice Antonioni
Concerto Omaggio A Beatrice AntonioniConcerto Omaggio A Beatrice Antonioni
Concerto Omaggio A Beatrice Antonioni
Angela Amato
 
Popular Music And Teaching Issues Power Point Presentation
Popular Music And Teaching Issues Power Point PresentationPopular Music And Teaching Issues Power Point Presentation
Popular Music And Teaching Issues Power Point Presentation
Angela Amato
 
Popular Music And Teaching Issues
Popular Music And Teaching IssuesPopular Music And Teaching Issues
Popular Music And Teaching Issues
Angela Amato
 
Sheila Nelson-Principi Fondamentali Del Metodo Didattico
Sheila Nelson-Principi Fondamentali Del Metodo DidatticoSheila Nelson-Principi Fondamentali Del Metodo Didattico
Sheila Nelson-Principi Fondamentali Del Metodo Didattico
Angela Amato
 
Tesi di Laurea-MA Music
Tesi di Laurea-MA MusicTesi di Laurea-MA Music
Tesi di Laurea-MA Music
Angela Amato
 
Temere
TemereTemere
Temere
guest7a78e2
 
Julie Franki Creative Portfolio
Julie Franki Creative PortfolioJulie Franki Creative Portfolio
Julie Franki Creative Portfolio
jfranki
 
Ebfm Slides 2009
Ebfm Slides 2009Ebfm Slides 2009
Ebfm Slides 2009
Whole Foods 4 Healthy Living
 
Presentation Tr Turkish Translation Of Legal Obligations
Presentation Tr Turkish Translation Of Legal ObligationsPresentation Tr Turkish Translation Of Legal Obligations
Presentation Tr Turkish Translation Of Legal Obligations
paul Billinge
 
Professional Portfolio Of Mohamed Ebrahim
Professional Portfolio Of Mohamed EbrahimProfessional Portfolio Of Mohamed Ebrahim
Professional Portfolio Of Mohamed Ebrahim
CPA Mohamed Ebrahim MBA Manchester, CGMA, ACMA, CIFE,
 
生命經驗傳承 人生經驗比賽
生命經驗傳承 人生經驗比賽生命經驗傳承 人生經驗比賽
生命經驗傳承 人生經驗比賽
edwardshen
 
Apples’ iPhone, iPod touch and iPad Application Programming - CLASS 1
Apples’ iPhone, iPod touch and iPad Application Programming - CLASS 1Apples’ iPhone, iPod touch and iPad Application Programming - CLASS 1
Apples’ iPhone, iPod touch and iPad Application Programming - CLASS 1
Violeta Salas
 
Mobile Marketing and Social Campaigns
Mobile Marketing and Social CampaignsMobile Marketing and Social Campaigns
Mobile Marketing and Social Campaigns
Violeta Salas
 
Class 02 Objective C
Class 02   Objective CClass 02   Objective C
Class 02 Objective C
Violeta Salas
 
Find your true passion and do what you love to do
Find your true passion and do what you love to doFind your true passion and do what you love to do
Find your true passion and do what you love to do
Violeta Salas
 
Self discipline - Brian Tracy
Self discipline - Brian TracySelf discipline - Brian Tracy
Self discipline - Brian Tracy
Violeta Salas
 
стратегии международной рекламы
стратегии международной рекламыстратегии международной рекламы
стратегии международной рекламы
dutik
 
Mobile marketing & Business
Mobile marketing & Business Mobile marketing & Business
Mobile marketing & Business
Violeta Salas
 
Concerto Omaggio A Beatrice Antonioni
Concerto Omaggio A Beatrice AntonioniConcerto Omaggio A Beatrice Antonioni
Concerto Omaggio A Beatrice Antonioni
Angela Amato
 
Popular Music And Teaching Issues Power Point Presentation
Popular Music And Teaching Issues Power Point PresentationPopular Music And Teaching Issues Power Point Presentation
Popular Music And Teaching Issues Power Point Presentation
Angela Amato
 
Popular Music And Teaching Issues
Popular Music And Teaching IssuesPopular Music And Teaching Issues
Popular Music And Teaching Issues
Angela Amato
 
Sheila Nelson-Principi Fondamentali Del Metodo Didattico
Sheila Nelson-Principi Fondamentali Del Metodo DidatticoSheila Nelson-Principi Fondamentali Del Metodo Didattico
Sheila Nelson-Principi Fondamentali Del Metodo Didattico
Angela Amato
 
Tesi di Laurea-MA Music
Tesi di Laurea-MA MusicTesi di Laurea-MA Music
Tesi di Laurea-MA Music
Angela Amato
 
Julie Franki Creative Portfolio
Julie Franki Creative PortfolioJulie Franki Creative Portfolio
Julie Franki Creative Portfolio
jfranki
 
Presentation Tr Turkish Translation Of Legal Obligations
Presentation Tr Turkish Translation Of Legal ObligationsPresentation Tr Turkish Translation Of Legal Obligations
Presentation Tr Turkish Translation Of Legal Obligations
paul Billinge
 
Ad

Similar to Going on an HTTP Diet: Front-End Web Performance (20)

Client Side Performance @ Xero
Client Side Performance @ XeroClient Side Performance @ Xero
Client Side Performance @ Xero
Craig Walker
 
Progressive downloads and rendering (Stoyan Stefanov)
Progressive downloads and rendering (Stoyan Stefanov)Progressive downloads and rendering (Stoyan Stefanov)
Progressive downloads and rendering (Stoyan Stefanov)
Ontico
 
Progressive Downloads and Rendering - take #2
Progressive Downloads and Rendering - take #2Progressive Downloads and Rendering - take #2
Progressive Downloads and Rendering - take #2
Stoyan Stefanov
 
High-Speed HTML5
High-Speed HTML5High-Speed HTML5
High-Speed HTML5
Peter Lubbers
 
CTU June 2011 - Things that Every ASP.NET Developer Should Know
CTU June 2011 - Things that Every ASP.NET Developer Should KnowCTU June 2011 - Things that Every ASP.NET Developer Should Know
CTU June 2011 - Things that Every ASP.NET Developer Should Know
Spiffy
 
High Performance Web Pages - 20 new best practices
High Performance Web Pages - 20 new best practicesHigh Performance Web Pages - 20 new best practices
High Performance Web Pages - 20 new best practices
Stoyan Stefanov
 
10 Tips to make your Website lightning-fast - SMX Stockholm 2012
10 Tips to make your Website lightning-fast - SMX Stockholm 201210 Tips to make your Website lightning-fast - SMX Stockholm 2012
10 Tips to make your Website lightning-fast - SMX Stockholm 2012
Bastian Grimm
 
Developing High Performance Web Apps - CodeMash 2011
Developing High Performance Web Apps - CodeMash 2011Developing High Performance Web Apps - CodeMash 2011
Developing High Performance Web Apps - CodeMash 2011
Timothy Fisher
 
Optimization of modern web applications
Optimization of modern web applicationsOptimization of modern web applications
Optimization of modern web applications
Eugene Lazutkin
 
High performance website
High performance websiteHigh performance website
High performance website
Chamnap Chhorn
 
performance.ppt
performance.pptperformance.ppt
performance.ppt
fakeaccount225095
 
DrupalCampLA 2011 - Drupal frontend-optimizing
DrupalCampLA 2011 - Drupal frontend-optimizingDrupalCampLA 2011 - Drupal frontend-optimizing
DrupalCampLA 2011 - Drupal frontend-optimizing
Ashok Modi
 
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
AD113  Speed Up Your Applications w/ Nginx and PageSpeedAD113  Speed Up Your Applications w/ Nginx and PageSpeed
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
edm00se
 
WordPress At Scale. WordCamp Dhaka 2019
WordPress At Scale. WordCamp Dhaka 2019WordPress At Scale. WordCamp Dhaka 2019
WordPress At Scale. WordCamp Dhaka 2019
Anam Ahmed
 
[In Control 2010] HTML5
[In Control 2010] HTML5[In Control 2010] HTML5
[In Control 2010] HTML5
Christopher Schmitt
 
Jinx - Malware 2.0
Jinx - Malware 2.0Jinx - Malware 2.0
Jinx - Malware 2.0
Itzik Kotler
 
Responsive content
Responsive contentResponsive content
Responsive content
honzie
 
Html5 shubelal
Html5 shubelalHtml5 shubelal
Html5 shubelal
Shub
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
Joram Salinas
 
Presentation on Instant page speed optimization
Presentation on Instant page speed optimizationPresentation on Instant page speed optimization
Presentation on Instant page speed optimization
Sanjeev Kumar Jaiswal
 
Client Side Performance @ Xero
Client Side Performance @ XeroClient Side Performance @ Xero
Client Side Performance @ Xero
Craig Walker
 
Progressive downloads and rendering (Stoyan Stefanov)
Progressive downloads and rendering (Stoyan Stefanov)Progressive downloads and rendering (Stoyan Stefanov)
Progressive downloads and rendering (Stoyan Stefanov)
Ontico
 
Progressive Downloads and Rendering - take #2
Progressive Downloads and Rendering - take #2Progressive Downloads and Rendering - take #2
Progressive Downloads and Rendering - take #2
Stoyan Stefanov
 
CTU June 2011 - Things that Every ASP.NET Developer Should Know
CTU June 2011 - Things that Every ASP.NET Developer Should KnowCTU June 2011 - Things that Every ASP.NET Developer Should Know
CTU June 2011 - Things that Every ASP.NET Developer Should Know
Spiffy
 
High Performance Web Pages - 20 new best practices
High Performance Web Pages - 20 new best practicesHigh Performance Web Pages - 20 new best practices
High Performance Web Pages - 20 new best practices
Stoyan Stefanov
 
10 Tips to make your Website lightning-fast - SMX Stockholm 2012
10 Tips to make your Website lightning-fast - SMX Stockholm 201210 Tips to make your Website lightning-fast - SMX Stockholm 2012
10 Tips to make your Website lightning-fast - SMX Stockholm 2012
Bastian Grimm
 
Developing High Performance Web Apps - CodeMash 2011
Developing High Performance Web Apps - CodeMash 2011Developing High Performance Web Apps - CodeMash 2011
Developing High Performance Web Apps - CodeMash 2011
Timothy Fisher
 
Optimization of modern web applications
Optimization of modern web applicationsOptimization of modern web applications
Optimization of modern web applications
Eugene Lazutkin
 
High performance website
High performance websiteHigh performance website
High performance website
Chamnap Chhorn
 
DrupalCampLA 2011 - Drupal frontend-optimizing
DrupalCampLA 2011 - Drupal frontend-optimizingDrupalCampLA 2011 - Drupal frontend-optimizing
DrupalCampLA 2011 - Drupal frontend-optimizing
Ashok Modi
 
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
AD113  Speed Up Your Applications w/ Nginx and PageSpeedAD113  Speed Up Your Applications w/ Nginx and PageSpeed
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
edm00se
 
WordPress At Scale. WordCamp Dhaka 2019
WordPress At Scale. WordCamp Dhaka 2019WordPress At Scale. WordCamp Dhaka 2019
WordPress At Scale. WordCamp Dhaka 2019
Anam Ahmed
 
Jinx - Malware 2.0
Jinx - Malware 2.0Jinx - Malware 2.0
Jinx - Malware 2.0
Itzik Kotler
 
Responsive content
Responsive contentResponsive content
Responsive content
honzie
 
Html5 shubelal
Html5 shubelalHtml5 shubelal
Html5 shubelal
Shub
 
Presentation on Instant page speed optimization
Presentation on Instant page speed optimizationPresentation on Instant page speed optimization
Presentation on Instant page speed optimization
Sanjeev Kumar Jaiswal
 
Ad

Recently uploaded (20)

Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 

Going on an HTTP Diet: Front-End Web Performance

  • 2. "Never underestimate the — CEO Eric Schmidt announcing Google Instant in September 2010
  • 6. The Low-Hanging Fruit The 20 / 80 rule
  • 7. I. Serve up lighter files II. Trim back on HTTP III. Keep things a-movin’ (avoid blocking)
  • 10. Image Optimization Images are often >50% of a page’s total weight!
  • 12. Leaner JPEGs: Quality
  • 14. Leaner JPEGs: Metadata
  • 15. Leaner JPEGs: Metadata command line ahoy! > jpegtran -copy none -optimize src.jpg dest.jpg
  • 17. Professional PNGs: bit depth
  • 19. Professional PNGs: 8bit alpha woes? •8bit PNGs CAN have full alpha support! •Use Adobe Fireworks instead •Or run them through pngquant
  • 20. Professional PNGs: PNGQUANT command line ahoy! > pngquant 256 whatever.png
  • 21. Professional PNGs: PNGCRUSH command line ahoy! > pngcrush -rem alla -reduce -brute source.png dest.png
  • 23. animated GIFs are back gifsicle can help
  • 24. Slimmer Text Fil The Rudimentary Approach • class=“whatever” → class=whatever • http://www.utexas.edu/law/whatever.html → /law/whatever.html • <script type=“text/javascript”> → <script> • Use CSS shorthand!
  • 25. Slimmer Text Fil Minify your scripts and other text jquery-1.6.3.js jquery-1.6.3.min.js
  • 26. Slimmer Text Fil Minify your scripts and other text • YUICompressor • Google's Closure Compiler • Dojo ShrinkSafe • Packer • JSMin
  • 27. Slimmer Text Fil Serious bandwidth savings with gzip For Apache 2.x*: <ifModule mod_deflate.c> AddOutputFilterByType DEFLATE text/html text/css application/x-javascript </ifModule> * Note: don’t do this on Web Central…
  • 28. Trim Back on HTTP Requests
  • 29. The Problem with HTTP Requests HTTP/1.1 specifies 2 maximum simultaneous TCP connections Source: HTTP/1.1 specification, RFC 2616 8.1.4 http://www.w3.org/Protocols/rfc2616/rfc2616- sec8.html#sec8
  • 30. The Problem with HTTP Requests HTTP/1.1 specifies 2 maximum simultaneous TCP connections (per domain) Source: HTTP/1.1 specification, RFC 2616 8.1.4 http://www.w3.org/Protocols/rfc2616/rfc2616- sec8.html#sec8
  • 31. HTTP Waterfall IE7 generated with http:// www.webpagetest.org/
  • 32. HTTP Waterfall - Chrome 14
  • 34. Fold print and media query styles
  • 35. Fold print and media query styles <link rel="stylesheet" href="styles.css" /> <link rel="stylesheet" href="print.css" />
  • 36. Fold print and media query styles /* Print styles in styles.css @media print { body { background: #fff; } }
  • 39. use PS: Maybe use CSS opacity to cut down on the number of button states in an image sprite?
  • 42. Data URIs • Prevents the opening of an additional TCP request
  • 43. Data URIs • Prevents the opening of an additional TCP request • Faster download than a separate image request
  • 44. Data URIs • Prevents the opening of an additional TCP request • Faster download than a separate image request • Can be created on the fly in PHP with base64_encode()
  • 45. Data URIs • Prevents the opening of an additional TCP request • Faster download than a separate image request • Can be created on the fly in PHP with base64_encode() • Are only cached if included inside of a stylesheet (not inline)
  • 46. Data URIs • Prevents the opening of an additional TCP request • Faster download than a separate image request • Can be created on the fly in PHP with base64_encode() • Are only cached if included inside of a stylesheet (not inline) • ~30% larger than “real” image files (~2% if gzip is enabled)
  • 47. Data URIs • Prevents the opening of an additional TCP request • Faster download than a separate image request • Can be created on the fly in PHP with base64_encode() • Are only cached if included inside of a stylesheet (not inline) • ~30% larger than “real” image files (~2% if gzip is enabled) • Wide browser support, but no IE 7 or older (and IE8 only supports up to 32KB of data)
  • 48. Cache: Far-Future Expires
  • 49. Cache: Far-Future Expires
  • 50. Cache: Far-Future Expires Stick this in your .htaccess <IfModule mod_expires.c> ExpiresActive on <FilesMatch ".(gif|jpg|png|js|css)$"> ExpiresDefault "access plus 5 years" </FilesMatch> </IfModule>
  • 51. Cache: Far-Future Expires Wait, why are they still seeing that version?!
  • 52. Cache: Far-Future Expires Wait, why are they still seeing that version?! • A good practice, but users might end up with old versions of styles and scripts…
  • 53. Cache: Far-Future Expires Wait, why are they still seeing that version?! • A good practice, but users might end up with old versions of styles and scripts… • To force a fresh download you can rename the file (I hope you’ve got a CMS or build process that makes this easy!)
  • 55. Cache: Disable ETags Another one for your .htaccess FileETag none
  • 56. Cache: Disable ETags Another one for your .htaccess FileETag none Recommended by Microsoft and Apache! http://support.microsoft.com/? id=922733 http://www.apacheweek.com/issues/ 02-0-18
  • 57. Stay in Motion (avoid resource blocking)
  • 58. Blocking (IE7 example)
  • 59. What can cause blocking?
  • 60. What can cause blocking? in • External scripts cause blocking, case of a document.write() and to ensure proper order of execution
  • 61. What can cause blocking? in • External scripts cause blocking, case of a document.write() and to ensure proper order of execution •Inline <script> can hang things up
  • 62. What can cause blocking? in • External scripts cause blocking, case of a document.write() and to ensure proper order of execution •Inline <script> can hang things up •Scripts often don’t execute until stylesheets are finished downloading
  • 63. What can cause blocking? in • External scripts cause blocking, case of a document.write() and to ensure proper order of execution •Inline <script> can hang things up •Scripts often don’t execute until stylesheets are finished downloading •CSS @import causes blocking in older IE
  • 64. What can cause blocking? in • External scripts cause blocking, case of a document.write() and to ensure proper order of execution •Inline <script> can hang things up •Scripts often don’t execute until stylesheets are finished downloading •CSS @import causes blocking in older IE •iframes can block onload from firing
  • 66. How do we get around this?
  • 67. How do we get around this? • Put stylesheets in the <head> using a <link> tag instead of @import
  • 68. How do we get around this? • Put stylesheets in the <head> using a <link> tag instead of @import • Put your scripts as close to the </body> tag as possible (in most circumstances)
  • 69. How do we get around this? • Put stylesheets in the <head> using a <link> tag instead of @import • Put your scripts as close to the </body> tag as possible (in most circumstances) • Use a script loader like LabJS or HeadJS
  • 70. How do we get around this? • Put stylesheets in the <head> using a <link> tag instead of @import • Put your scripts as close to the </body> tag as possible (in most circumstances) • Use a script loader like LabJS or HeadJS • Use non-blocking script insertion techniques like XHR Injection **
  • 71. Asynchronous Script Insertion (function () { var ga = document.createElement('script'), s = document.getElementsByTagName('script')[0]; ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' === document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; s.parentNode.insertBefore(ga, s); }());
  • 73. Forward-looking approaches • <script defer> (wide browser support, but execution order?)
  • 74. Forward-looking approaches • <script defer> (wide browser support, but execution order?) • <script async> (HTML5, widening support, but no IE)
  • 75. Forward-looking approaches • <script defer> (wide browser support, but execution order?) • <script async> (HTML5, widening support, but no IE) • Web Workers (Multi-threaded JS processing! But no IE…)
  • 76. DEMO YSlow PageSpeed

Editor's Notes