SlideShare a Scribd company logo
1 of 32
Download to read offline
DRUPAL – FRONTEND
PERFORMANCE
Ashok Modi – DrupalCampLA 2011
About me
    Computer Systems Analyst at the California Institute
     of the Arts (http://calarts.edu)
      Seemy profile at http://drupal.org/user/60422
      Read my thoughts at http://btmash.com/

    Strong interest in Server Optimization.
      Frontend   and Backend
About this presentation
    “Backend” optimizations to speed up the frontend.
       Show  settings to tune on server for faster downloads by user
       Useful modules.
       Unless stated, assuming backend server is apache

    CSS & Javascript
       Things   to help make it faster.
  There will be some level of back and forth between the
   two.
  Have a question? Ask!

  Have something to share? Come on up!
Resources
    Konstantin Kaefer
      http://kkaefer.com

    Steve Souders
      http://stevesouders.com/blog

    Wim Leers
      http://wimleers.com

    Addy Osmani
      http://addyosmani.com
Goals
    Define your objectives and goals first
       Do you want a faster response to the end user per page?
       Do you want to handle more page views?
       Do you want to minimize downtime?

  Related…but different
  Sometimes, there are ‘low hanging fruit’ that are easy to see
   and provide noticeable improvements
  Gets hard to achieve more performance (more effort, fewer
   gains)
       More  infrastructure?
       Revisions at the JS/CSS Layer?
       Revisions at the theme layer?
Diagnosis
  Proper diagnosis is essential before proposing and
   implementing a solution, or you’re running blind.
  Based on proper data.

      Analyze.

    Can lead to a few possible paths of optimization.
Points of optimization.
1    Introduction
2    Tools to measure and diagnose
3    Speed optimizations
‘Media’
    Loading images, stylesheets, javascript can account
     for more than 80% of total load time.
      Overall  load time?
      Page size?

      Time until DOM is loaded?

      Time until page is rendered?

      Time until
       page is
       functional?
Tools to measure and diagnose
    Firebug’s Net Panel
         Track loading time for stylesheets, javascript, images, and total page load time.
    Yslow
         Rates a webpage based on many criteria.
         Determines overall load time.
         Provides optimization suggestions.
         Provides page statistics.
    Google Page Speed
         Similar to Yslow.
         Provides suggestions on improving CSS, optimizing image files, and minimizing
          javascript.
    Google Chrome Developer Panel
         Very powerful.
         Auditor helps track speed of js.
Tools to measure and diagnose (cont’d)

    Episodes
      Aimed to measure timing of web 2.0 applications.
      Granular measurements on how sections perform.

      Drupal module (http://drupal.org/project/episodes)
Non-Browser Tools
    AOL Page Test
       http://webpagetest.org

    Pingdom
       http://tools.pingdom.com
       Waterfall    diagram
    JSPerf
       http://jsperf.com
       Test   out snippets of javascript
    CSSLint
       http://csslint.com
       Check    and see suggestions on improving your CSS.
Backend Suggestion 1: Reduce
Requests
  Every file produces an HTTP Request
  Fewer requests of large files are better than many

   smaller files (fewer server resources per user).
  Current browsers can download atleast 4

   components per host in parallel.
Reduce Requests (cont’d)
    Combine sprites together
       Many    images in one file.
       Shift into view with CSS via
        background-position.
    Aggregate scripts and styles
       Built
           into Drupal
       NOTE: Drupal 7 splits up into many more files than before.
          Not  as ‘efficient’ in some ways as D6.
          Pay attention to what happens with Bundle Cache at WPO
           (http://drupal.org/project/wpo)
Reduce Requests (cont’d)
    Use CSS instead of images
      border-radius,-moz-border-radius,
       -webkit-border-radius for rounded corners
    Use image data in CSS
      background:url(data:image/gif;base64,R0lGODlhEAAOALMAAOazToeHh0tLS/7LZv/0jvb29t/
       f3//Ub/ /ge8WSLf/rhf/3kdbW1mxsbP//mf///
       yH5BAAAAAAALAAAAAAQAA4AAARe8L1Ekyky67QZ1hLnjM5UUde0ECwLJoExK
       cppV0aCcGCmTIHEIUEqjgaORCMxIC6e0CcguWw6aFjsVMkkIr7g77ZKPJjPZqIyd7sJAgVGoEG
       v2xsBxqNgYPj/gAwXEQA7) top left no-repeat;)

    Similarly, use font-data in CSS
Backend Suggestion 2: CDN
    Content Delivery Network.
    Lots of servers scattered around the world.
    Reduces roundtrip times.
    Example: using a CDN on one of my
     sites increased the requests/second
     from 150 r/s to 200 r/s.
    Can be inexpensive for hosting
     static files (7 cents/ GB)
    Akamai
    MaxCDN
    Cachefly
    Amazon Cloudfront
    Softlayer Cloudlayer
Backend Suggestion 3: Caching
Caching (cont’d)
  Controlled by HTTP Headers
  Browsers check if the content is ‘fresh’

  Set expires header to a date in the future

  <location /css>
   ExpiresActive on
   ExpiresDefault “access plus 2 weeks”
   </location>
   ExpiresByType “access plus 1 month”
  For nginx: location ~* ^.+.(css|js)$ { expires 30d; }

  Change filenames / url when updating.
Backend Suggestion #4: GZIP
    Compress text content
      <IfModule   mod_deflate.c>
       AddOutputFilterByType DEFLATE text/css application/
       x-javascript
       </IfModule>
      For nginx: http://goo.gl/PeDp

    Vastly reduces page size
      http://redcat.org:
                        700kb -> 380kb (CSS went down
       from 120kb to 25kb)
Backend Suggestion #5: Parallelization

    Most browsers allow for more than 2 connections per host
       IE8+:6
       FF3+: 6
       Chrome: 6
       Safari: 4
       Opera: 4

    More hosts = more parallel downloads at same time.
       Don’t   overdo it!
    CDN (http://drupal.org/project/cdn)
       Doesn’t  have to be tied to a CDN
       Point to your server with a different domain and users can
        download more of page at same time.
Backend Suggestion #6: Persistent
HTTP
    Apache / NGINX support persistent connections




  Reconnecting over and over again takes time.
  Make sure KeepAlive is not turned off.
Backend Suggestion #7: Remove
unnecessary cruft
    Apache enables ‘modules’ like mod_cgi,
     mod_proxy, mod_dav by default.
      More  likely than not, you do not need them.
      Disabling will lower the memory usage by apache on a
       per connection basis.
      More users.

  NginX starts off fairly lightweight and you have to
   add modules.
  Varnish makes no difference.
Theme Suggestion #1: CSS on TOP
  Placed in <head>
  Page is rendered when all css in header is loaded

  Loading CSS later causes re-rendering and user will
   see flash of unstyled content.
  <link> is faster than @import

      But @import allows to use more than 32 files from IE
       restriction.
      Drupal automatically handles itself between the two 
Theme Suggestion #2
  Placed right before </body>.
  Loading scripts blocks page rendering.

       Downloading    JS files will block downloads of other file
       types.
  Scripts are downloaded sequentially.
  Use graceful degradation.

       Don’t   have onfoo event handlers in the code.



                           JS at the BOTTOM
Theme Suggestion #3: Minify JS/CSS

  Remove comments / whitespace.
  Great savings, even more with gzip

  No real modules for D7

      Simple  solution: Create a regular version of your file(s).
       Use a 3rd party tool (Google Closure Compiler) to
       minify/pack and use that.
      CSS is slightly minified. But use Page Speed to get rid
       of unused CSS.
Theme Suggestion #4: Reduce image
size
    OptiPNG, PNGCrush
       Removes   invisible content
       Lossless compression
    JPEGTran/Imagemagick
       Remove   color profiles / metadata
       Lossless JPEG operations

  http://smushit.com
  Google Page Speed also reports how much image can
   be compressed.
  User uploaded images can be compress for size by
   imagecache (D6) or in core (D7)
Theme suggestion #4: Lazy
initialization
    Javascript takes time to initialize.
      Librariessuch as jQuery also count.
      Defer setup work.

    Load images only when they need to be displayed.
      Initial
             load on old calarts.edu website: 650kb.
      After js lazy load: 250kb.

    Only load content above the fold.
      Findout more at http://goo.gl/lpH4r
      Very useful on image heavy sites.
CSS Improvements
  For the most part…fairly small gains
  Recent recommendations say to try and use classes as
   opposed to IDs
       Performance  difference is tiny.
       Classes are much more flexible.
  Try to limit yourself to a second level selector (.class-
   one .child-class-two) especially if you use CSS3
   selectors (.class:not(a), etc)
  Google Page Speed helps show which of your selectors
   could be improved.
  DEMO
jQuery improvements
    Newer releases of jQuery are generally faster.
       jQuery   Update module might be worthwhile to look at.
    Small tip: If you are going to call on the same selector(s)
     over and over, save them to a variable.
       Should   be a nice speed boost.
    Large area
       Not all selectors are created equal 
       ID and Element selectors are the fastest.
       Class selectors are slightly slower.
       Pseudo/Attribute selectors are the slowest

    Can test out a chunk of this at http://jsperf.com (used by
     jQuery team)
jQuery improvements (cont’d)
  Context vs. Find vs. Children vs…
  Find ($parent.find(‘.child’)) is slightly faster than context
   ($(‘.child’, $parent)) since the latter has to get parsed.
  $parent.children() – 50% slower.

  $(‘#parent > .child’) – 70% slower.

  $(‘#parent .child) – ~80% slower.

  $(‘#parent’).find(‘.child’) is about 16% slower than the
   fastest (since the #parent has to be fetched from the
   DOM)
       As said before, best to get the $(‘#parent’) object stored
       into a variable if it will be reused later.
jQuery improvements (cont’d)
    You don’t always have to use jQuery.
         $(item).attr(‘id’) is 80 – 90% slower than item.id
              Apparently, item.id is also more up-to-date.
    Did I mention cache (store the result of) your result to a variable? 
         http://jsperf.com/ns-jq-cached – This uncached is 56% slower on my
          computer.
    Chaining your methods on a selector ($
     (‘#item’).doSomething().doSomethingElse()) is generally faster than
     separate calls.
    Try and keep your append() calls to a minimum if you absolutely
     need them.
         Can be very costly (up to 90% decrease in performance)
jQuery optimizations (cont’d)
    Try and bind event to as high of a parent as you
     possibly can.
       Works       with child elements at runtime and all those injected
        later.
       .bind() doesn’t automatically work with dynamically inserted
        elements
         .live()
               allows for this though you cannot chain methods and really
         only for simple tasks.
  Working with modifying content by using detach() could
   provide a big boost in performance.
  while loops are faster than each() and $.each()
Questions?
    Interested in talking more? I sure am!
      Let’s   talk after 
    What other presentations might be related and/or
     useful?
      Drupal Design Skills 2012
      Drupal Theme Design Q&A Panel

      Designing Future Proof Websites

    Thank you! 

More Related Content

What's hot

Anthony Somerset - Site Speed = Success!
Anthony Somerset - Site Speed = Success!Anthony Somerset - Site Speed = Success!
Anthony Somerset - Site Speed = Success!WordCamp Cape Town
 
Best Practices for WordPress in Enterprise
Best Practices for WordPress in EnterpriseBest Practices for WordPress in Enterprise
Best Practices for WordPress in EnterpriseTaylor Lovett
 
Drupal Performance : DrupalCamp North
Drupal Performance : DrupalCamp NorthDrupal Performance : DrupalCamp North
Drupal Performance : DrupalCamp NorthPhilip Norton
 
Drupal in 30 Minutes
Drupal in 30 MinutesDrupal in 30 Minutes
Drupal in 30 MinutesRobert Carr
 
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 itOtto Kekäläinen
 
WordPress At Scale. WordCamp Dhaka 2019
WordPress At Scale. WordCamp Dhaka 2019WordPress At Scale. WordCamp Dhaka 2019
WordPress At Scale. WordCamp Dhaka 2019Anam Ahmed
 
Drupal performance optimization Best Practices
Drupal performance optimization Best PracticesDrupal performance optimization Best Practices
Drupal performance optimization Best PracticesRatnesh kumar, CSM
 
Drupal, varnish, esi - Toulouse November 2
Drupal, varnish, esi - Toulouse November 2Drupal, varnish, esi - Toulouse November 2
Drupal, varnish, esi - Toulouse November 2Marcus Deglos
 
Pure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talkPure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talkBryan Ollendyke
 
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDaysLuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDaysLuis Rodríguez Castromil
 
Saving Time with WP-CLI
Saving Time with WP-CLISaving Time with WP-CLI
Saving Time with WP-CLITaylor Lovett
 
Going on an HTTP Diet: Front-End Web Performance
Going on an HTTP Diet: Front-End Web PerformanceGoing on an HTTP Diet: Front-End Web Performance
Going on an HTTP Diet: Front-End Web PerformanceAdam Norwood
 
SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...
SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...
SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...Sencha
 
Aem dispatcher – tips & tricks
Aem dispatcher – tips & tricksAem dispatcher – tips & tricks
Aem dispatcher – tips & tricksAshokkumar T A
 
Use Xdebug to profile PHP
Use Xdebug to profile PHPUse Xdebug to profile PHP
Use Xdebug to profile PHPSeravo
 
Implementing High Performance Drupal Sites
Implementing High Performance Drupal SitesImplementing High Performance Drupal Sites
Implementing High Performance Drupal SitesShri Kumar
 
Roy foubister (hosting high traffic sites on a tight budget)
Roy foubister (hosting high traffic sites on a tight budget)Roy foubister (hosting high traffic sites on a tight budget)
Roy foubister (hosting high traffic sites on a tight budget)WordCamp Cape Town
 
The 5 most common reasons for a slow WordPress site and how to fix them – ext...
The 5 most common reasons for a slow WordPress site and how to fix them – ext...The 5 most common reasons for a slow WordPress site and how to fix them – ext...
The 5 most common reasons for a slow WordPress site and how to fix them – ext...Otto Kekäläinen
 
JSON REST API for WordPress
JSON REST API for WordPressJSON REST API for WordPress
JSON REST API for WordPressTaylor Lovett
 

What's hot (20)

Anthony Somerset - Site Speed = Success!
Anthony Somerset - Site Speed = Success!Anthony Somerset - Site Speed = Success!
Anthony Somerset - Site Speed = Success!
 
Best Practices for WordPress in Enterprise
Best Practices for WordPress in EnterpriseBest Practices for WordPress in Enterprise
Best Practices for WordPress in Enterprise
 
Drupal Performance : DrupalCamp North
Drupal Performance : DrupalCamp NorthDrupal Performance : DrupalCamp North
Drupal Performance : DrupalCamp North
 
Drupal in 30 Minutes
Drupal in 30 MinutesDrupal in 30 Minutes
Drupal in 30 Minutes
 
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
 
WordPress At Scale. WordCamp Dhaka 2019
WordPress At Scale. WordCamp Dhaka 2019WordPress At Scale. WordCamp Dhaka 2019
WordPress At Scale. WordCamp Dhaka 2019
 
Drupal performance optimization Best Practices
Drupal performance optimization Best PracticesDrupal performance optimization Best Practices
Drupal performance optimization Best Practices
 
Drupal, varnish, esi - Toulouse November 2
Drupal, varnish, esi - Toulouse November 2Drupal, varnish, esi - Toulouse November 2
Drupal, varnish, esi - Toulouse November 2
 
Pure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talkPure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talk
 
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDaysLuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
 
Saving Time with WP-CLI
Saving Time with WP-CLISaving Time with WP-CLI
Saving Time with WP-CLI
 
Going on an HTTP Diet: Front-End Web Performance
Going on an HTTP Diet: Front-End Web PerformanceGoing on an HTTP Diet: Front-End Web Performance
Going on an HTTP Diet: Front-End Web Performance
 
SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...
SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...
SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...
 
Varnish bof
Varnish bofVarnish bof
Varnish bof
 
Aem dispatcher – tips & tricks
Aem dispatcher – tips & tricksAem dispatcher – tips & tricks
Aem dispatcher – tips & tricks
 
Use Xdebug to profile PHP
Use Xdebug to profile PHPUse Xdebug to profile PHP
Use Xdebug to profile PHP
 
Implementing High Performance Drupal Sites
Implementing High Performance Drupal SitesImplementing High Performance Drupal Sites
Implementing High Performance Drupal Sites
 
Roy foubister (hosting high traffic sites on a tight budget)
Roy foubister (hosting high traffic sites on a tight budget)Roy foubister (hosting high traffic sites on a tight budget)
Roy foubister (hosting high traffic sites on a tight budget)
 
The 5 most common reasons for a slow WordPress site and how to fix them – ext...
The 5 most common reasons for a slow WordPress site and how to fix them – ext...The 5 most common reasons for a slow WordPress site and how to fix them – ext...
The 5 most common reasons for a slow WordPress site and how to fix them – ext...
 
JSON REST API for WordPress
JSON REST API for WordPressJSON REST API for WordPress
JSON REST API for WordPress
 

Viewers also liked

2011-11 UW Foster School of Business - Community Development
2011-11 UW Foster School of Business - Community Development2011-11 UW Foster School of Business - Community Development
2011-11 UW Foster School of Business - Community DevelopmentGillian Muessig
 
Search Ranking Factors Trends 2011 SEMStandard
Search Ranking Factors Trends 2011 SEMStandardSearch Ranking Factors Trends 2011 SEMStandard
Search Ranking Factors Trends 2011 SEMStandardGillian Muessig
 
2012-04 Inbound Marketing; Survival in Classified Ads
2012-04 Inbound Marketing; Survival in Classified Ads2012-04 Inbound Marketing; Survival in Classified Ads
2012-04 Inbound Marketing; Survival in Classified AdsGillian Muessig
 
EYP Greece - think bank
EYP Greece - think bankEYP Greece - think bank
EYP Greece - think bankdimhap
 
Presentation : EYP Greece
Presentation : EYP GreecePresentation : EYP Greece
Presentation : EYP Greecedimhap
 
παρουσίαση EYP
παρουσίαση EYPπαρουσίαση EYP
παρουσίαση EYPdimhap
 

Viewers also liked (6)

2011-11 UW Foster School of Business - Community Development
2011-11 UW Foster School of Business - Community Development2011-11 UW Foster School of Business - Community Development
2011-11 UW Foster School of Business - Community Development
 
Search Ranking Factors Trends 2011 SEMStandard
Search Ranking Factors Trends 2011 SEMStandardSearch Ranking Factors Trends 2011 SEMStandard
Search Ranking Factors Trends 2011 SEMStandard
 
2012-04 Inbound Marketing; Survival in Classified Ads
2012-04 Inbound Marketing; Survival in Classified Ads2012-04 Inbound Marketing; Survival in Classified Ads
2012-04 Inbound Marketing; Survival in Classified Ads
 
EYP Greece - think bank
EYP Greece - think bankEYP Greece - think bank
EYP Greece - think bank
 
Presentation : EYP Greece
Presentation : EYP GreecePresentation : EYP Greece
Presentation : EYP Greece
 
παρουσίαση EYP
παρουσίαση EYPπαρουσίαση EYP
παρουσίαση EYP
 

Similar to DrupalCampLA 2011 - Drupal frontend-optimizing

Drupal Frontend Performance and Scalability
Drupal Frontend Performance and ScalabilityDrupal Frontend Performance and Scalability
Drupal Frontend Performance and ScalabilityAshok Modi
 
Building high performance web apps.
Building high performance web apps.Building high performance web apps.
Building high performance web apps.Arshak Movsisyan
 
Frontend performance
Frontend performanceFrontend performance
Frontend performancesacred 8
 
Performace optimization (increase website speed)
Performace optimization (increase website speed)Performace optimization (increase website speed)
Performace optimization (increase website speed)clickramanm
 
Make Drupal Run Fast - increase page load speed
Make Drupal Run Fast - increase page load speedMake Drupal Run Fast - increase page load speed
Make Drupal Run Fast - increase page load speedAndy Kucharski
 
Web Client Performance
Web Client PerformanceWeb Client Performance
Web Client PerformanceHerea Adrian
 
Improving Drupal Performances
Improving Drupal PerformancesImproving Drupal Performances
Improving Drupal PerformancesVladimir Ilic
 
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 2012Bastian Grimm
 
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 2013Bastian Grimm
 
Front end performance optimization
Front end performance optimizationFront end performance optimization
Front end performance optimizationStevie T
 
Introduction to Optimizing WordPress for Website Speed
Introduction to Optimizing WordPress for Website SpeedIntroduction to Optimizing WordPress for Website Speed
Introduction to Optimizing WordPress for Website SpeedNile Flores
 
Drupal performance and scalability
Drupal performance and scalabilityDrupal performance and scalability
Drupal performance and scalabilityTwinbit
 
Client Side Performance @ Xero
Client Side Performance @ XeroClient Side Performance @ Xero
Client Side Performance @ XeroCraig Walker
 
High Performance Ajax Applications
High Performance Ajax ApplicationsHigh Performance Ajax Applications
High Performance Ajax ApplicationsSiarhei Barysiuk
 
implement lighthouse-ci with your web development workflow
implement lighthouse-ci with your web development workflowimplement lighthouse-ci with your web development workflow
implement lighthouse-ci with your web development workflowWordPress
 
Measuring Web Performance
Measuring Web Performance Measuring Web Performance
Measuring Web Performance Dave Olsen
 

Similar to DrupalCampLA 2011 - Drupal frontend-optimizing (20)

Drupal Frontend Performance and Scalability
Drupal Frontend Performance and ScalabilityDrupal Frontend Performance and Scalability
Drupal Frontend Performance and Scalability
 
Building high performance web apps.
Building high performance web apps.Building high performance web apps.
Building high performance web apps.
 
Frontend performance
Frontend performanceFrontend performance
Frontend performance
 
Speed!
Speed!Speed!
Speed!
 
Performace optimization (increase website speed)
Performace optimization (increase website speed)Performace optimization (increase website speed)
Performace optimization (increase website speed)
 
Make Drupal Run Fast - increase page load speed
Make Drupal Run Fast - increase page load speedMake Drupal Run Fast - increase page load speed
Make Drupal Run Fast - increase page load speed
 
Web Client Performance
Web Client PerformanceWeb Client Performance
Web Client Performance
 
Improving Drupal Performances
Improving Drupal PerformancesImproving Drupal Performances
Improving Drupal Performances
 
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
 
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
 
Front end performance optimization
Front end performance optimizationFront end performance optimization
Front end performance optimization
 
Front-end performances
Front-end performancesFront-end performances
Front-end performances
 
Introduction to Optimizing WordPress for Website Speed
Introduction to Optimizing WordPress for Website SpeedIntroduction to Optimizing WordPress for Website Speed
Introduction to Optimizing WordPress for Website Speed
 
Drupal performance and scalability
Drupal performance and scalabilityDrupal performance and scalability
Drupal performance and scalability
 
Client Side Performance @ Xero
Client Side Performance @ XeroClient Side Performance @ Xero
Client Side Performance @ Xero
 
Html Optimization for SEO
Html Optimization for SEOHtml Optimization for SEO
Html Optimization for SEO
 
High Performance Ajax Applications
High Performance Ajax ApplicationsHigh Performance Ajax Applications
High Performance Ajax Applications
 
Browser Caching
Browser CachingBrowser Caching
Browser Caching
 
implement lighthouse-ci with your web development workflow
implement lighthouse-ci with your web development workflowimplement lighthouse-ci with your web development workflow
implement lighthouse-ci with your web development workflow
 
Measuring Web Performance
Measuring Web Performance Measuring Web Performance
Measuring Web Performance
 

Recently uploaded

TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Recently uploaded (20)

TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

DrupalCampLA 2011 - Drupal frontend-optimizing

  • 1. DRUPAL – FRONTEND PERFORMANCE Ashok Modi – DrupalCampLA 2011
  • 2. About me   Computer Systems Analyst at the California Institute of the Arts (http://calarts.edu)  Seemy profile at http://drupal.org/user/60422  Read my thoughts at http://btmash.com/   Strong interest in Server Optimization.  Frontend and Backend
  • 3. About this presentation   “Backend” optimizations to speed up the frontend.   Show settings to tune on server for faster downloads by user   Useful modules.   Unless stated, assuming backend server is apache   CSS & Javascript   Things to help make it faster.   There will be some level of back and forth between the two.   Have a question? Ask!   Have something to share? Come on up!
  • 4. Resources   Konstantin Kaefer  http://kkaefer.com   Steve Souders  http://stevesouders.com/blog   Wim Leers  http://wimleers.com   Addy Osmani  http://addyosmani.com
  • 5. Goals   Define your objectives and goals first   Do you want a faster response to the end user per page?   Do you want to handle more page views?   Do you want to minimize downtime?   Related…but different   Sometimes, there are ‘low hanging fruit’ that are easy to see and provide noticeable improvements   Gets hard to achieve more performance (more effort, fewer gains)   More infrastructure?   Revisions at the JS/CSS Layer?   Revisions at the theme layer?
  • 6. Diagnosis   Proper diagnosis is essential before proposing and implementing a solution, or you’re running blind.   Based on proper data.  Analyze.   Can lead to a few possible paths of optimization.
  • 7. Points of optimization. 1  Introduction 2  Tools to measure and diagnose 3  Speed optimizations
  • 8. ‘Media’   Loading images, stylesheets, javascript can account for more than 80% of total load time.  Overall load time?  Page size?  Time until DOM is loaded?  Time until page is rendered?  Time until page is functional?
  • 9. Tools to measure and diagnose   Firebug’s Net Panel   Track loading time for stylesheets, javascript, images, and total page load time.   Yslow   Rates a webpage based on many criteria.   Determines overall load time.   Provides optimization suggestions.   Provides page statistics.   Google Page Speed   Similar to Yslow.   Provides suggestions on improving CSS, optimizing image files, and minimizing javascript.   Google Chrome Developer Panel   Very powerful.   Auditor helps track speed of js.
  • 10. Tools to measure and diagnose (cont’d)   Episodes  Aimed to measure timing of web 2.0 applications.  Granular measurements on how sections perform.  Drupal module (http://drupal.org/project/episodes)
  • 11. Non-Browser Tools   AOL Page Test   http://webpagetest.org   Pingdom   http://tools.pingdom.com   Waterfall diagram   JSPerf   http://jsperf.com   Test out snippets of javascript   CSSLint   http://csslint.com   Check and see suggestions on improving your CSS.
  • 12. Backend Suggestion 1: Reduce Requests   Every file produces an HTTP Request   Fewer requests of large files are better than many smaller files (fewer server resources per user).   Current browsers can download atleast 4 components per host in parallel.
  • 13. Reduce Requests (cont’d)   Combine sprites together   Many images in one file.   Shift into view with CSS via background-position.   Aggregate scripts and styles   Built into Drupal   NOTE: Drupal 7 splits up into many more files than before.   Not as ‘efficient’ in some ways as D6.   Pay attention to what happens with Bundle Cache at WPO (http://drupal.org/project/wpo)
  • 14. Reduce Requests (cont’d)   Use CSS instead of images  border-radius,-moz-border-radius, -webkit-border-radius for rounded corners   Use image data in CSS  background:url(data:image/gif;base64,R0lGODlhEAAOALMAAOazToeHh0tLS/7LZv/0jvb29t/ f3//Ub/ /ge8WSLf/rhf/3kdbW1mxsbP//mf/// yH5BAAAAAAALAAAAAAQAA4AAARe8L1Ekyky67QZ1hLnjM5UUde0ECwLJoExK cppV0aCcGCmTIHEIUEqjgaORCMxIC6e0CcguWw6aFjsVMkkIr7g77ZKPJjPZqIyd7sJAgVGoEG v2xsBxqNgYPj/gAwXEQA7) top left no-repeat;)   Similarly, use font-data in CSS
  • 15. Backend Suggestion 2: CDN   Content Delivery Network.   Lots of servers scattered around the world.   Reduces roundtrip times.   Example: using a CDN on one of my sites increased the requests/second from 150 r/s to 200 r/s.   Can be inexpensive for hosting static files (7 cents/ GB)   Akamai   MaxCDN   Cachefly   Amazon Cloudfront   Softlayer Cloudlayer
  • 17. Caching (cont’d)   Controlled by HTTP Headers   Browsers check if the content is ‘fresh’   Set expires header to a date in the future   <location /css> ExpiresActive on ExpiresDefault “access plus 2 weeks” </location> ExpiresByType “access plus 1 month”   For nginx: location ~* ^.+.(css|js)$ { expires 30d; }   Change filenames / url when updating.
  • 18. Backend Suggestion #4: GZIP   Compress text content  <IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/css application/ x-javascript </IfModule>  For nginx: http://goo.gl/PeDp   Vastly reduces page size  http://redcat.org: 700kb -> 380kb (CSS went down from 120kb to 25kb)
  • 19. Backend Suggestion #5: Parallelization   Most browsers allow for more than 2 connections per host   IE8+:6   FF3+: 6   Chrome: 6   Safari: 4   Opera: 4   More hosts = more parallel downloads at same time.   Don’t overdo it!   CDN (http://drupal.org/project/cdn)   Doesn’t have to be tied to a CDN   Point to your server with a different domain and users can download more of page at same time.
  • 20. Backend Suggestion #6: Persistent HTTP   Apache / NGINX support persistent connections   Reconnecting over and over again takes time.   Make sure KeepAlive is not turned off.
  • 21. Backend Suggestion #7: Remove unnecessary cruft   Apache enables ‘modules’ like mod_cgi, mod_proxy, mod_dav by default.  More likely than not, you do not need them.  Disabling will lower the memory usage by apache on a per connection basis.  More users.   NginX starts off fairly lightweight and you have to add modules.   Varnish makes no difference.
  • 22. Theme Suggestion #1: CSS on TOP   Placed in <head>   Page is rendered when all css in header is loaded   Loading CSS later causes re-rendering and user will see flash of unstyled content.   <link> is faster than @import  But @import allows to use more than 32 files from IE restriction.  Drupal automatically handles itself between the two 
  • 23. Theme Suggestion #2   Placed right before </body>.   Loading scripts blocks page rendering.   Downloading JS files will block downloads of other file types.   Scripts are downloaded sequentially.   Use graceful degradation.   Don’t have onfoo event handlers in the code. JS at the BOTTOM
  • 24. Theme Suggestion #3: Minify JS/CSS   Remove comments / whitespace.   Great savings, even more with gzip   No real modules for D7  Simple solution: Create a regular version of your file(s). Use a 3rd party tool (Google Closure Compiler) to minify/pack and use that.  CSS is slightly minified. But use Page Speed to get rid of unused CSS.
  • 25. Theme Suggestion #4: Reduce image size   OptiPNG, PNGCrush   Removes invisible content   Lossless compression   JPEGTran/Imagemagick   Remove color profiles / metadata   Lossless JPEG operations   http://smushit.com   Google Page Speed also reports how much image can be compressed.   User uploaded images can be compress for size by imagecache (D6) or in core (D7)
  • 26. Theme suggestion #4: Lazy initialization   Javascript takes time to initialize.  Librariessuch as jQuery also count.  Defer setup work.   Load images only when they need to be displayed.  Initial load on old calarts.edu website: 650kb.  After js lazy load: 250kb.   Only load content above the fold.  Findout more at http://goo.gl/lpH4r  Very useful on image heavy sites.
  • 27. CSS Improvements   For the most part…fairly small gains   Recent recommendations say to try and use classes as opposed to IDs   Performance difference is tiny.   Classes are much more flexible.   Try to limit yourself to a second level selector (.class- one .child-class-two) especially if you use CSS3 selectors (.class:not(a), etc)   Google Page Speed helps show which of your selectors could be improved.   DEMO
  • 28. jQuery improvements   Newer releases of jQuery are generally faster.   jQuery Update module might be worthwhile to look at.   Small tip: If you are going to call on the same selector(s) over and over, save them to a variable.   Should be a nice speed boost.   Large area   Not all selectors are created equal    ID and Element selectors are the fastest.   Class selectors are slightly slower.   Pseudo/Attribute selectors are the slowest   Can test out a chunk of this at http://jsperf.com (used by jQuery team)
  • 29. jQuery improvements (cont’d)   Context vs. Find vs. Children vs…   Find ($parent.find(‘.child’)) is slightly faster than context ($(‘.child’, $parent)) since the latter has to get parsed.   $parent.children() – 50% slower.   $(‘#parent > .child’) – 70% slower.   $(‘#parent .child) – ~80% slower.   $(‘#parent’).find(‘.child’) is about 16% slower than the fastest (since the #parent has to be fetched from the DOM)   As said before, best to get the $(‘#parent’) object stored into a variable if it will be reused later.
  • 30. jQuery improvements (cont’d)   You don’t always have to use jQuery.   $(item).attr(‘id’) is 80 – 90% slower than item.id   Apparently, item.id is also more up-to-date.   Did I mention cache (store the result of) your result to a variable?    http://jsperf.com/ns-jq-cached – This uncached is 56% slower on my computer.   Chaining your methods on a selector ($ (‘#item’).doSomething().doSomethingElse()) is generally faster than separate calls.   Try and keep your append() calls to a minimum if you absolutely need them.   Can be very costly (up to 90% decrease in performance)
  • 31. jQuery optimizations (cont’d)   Try and bind event to as high of a parent as you possibly can.   Works with child elements at runtime and all those injected later.   .bind() doesn’t automatically work with dynamically inserted elements   .live() allows for this though you cannot chain methods and really only for simple tasks.   Working with modifying content by using detach() could provide a big boost in performance.   while loops are faster than each() and $.each()
  • 32. Questions?   Interested in talking more? I sure am!  Let’s talk after    What other presentations might be related and/or useful?  Drupal Design Skills 2012  Drupal Theme Design Q&A Panel  Designing Future Proof Websites   Thank you! 