SlideShare una empresa de Scribd logo
1 de 10
Front-end Performance Optimization
Using Drupal
Fixing all validation errors reported by the Yslow & Page Speed tools.
Introduction
 The performance-enhancing concepts that guide
this presentation I first found outlined in these
two books:
 High Performance Websites
http://www.amazon.com/High-Performance-Web-Sites-Essential/dp/0596529309
 Even Faster Websites
http://www.amazon.com/Even-Faster-Web-Sites-Performance/dp/0596522304/
 It’s best to use both the Google and Yahoo! Page Speed Validation
Tools -
And try to comply with all of the suggestions they give:
 Google’s Resource on the subject:
http://code.google.com/speed/page-speed/docs/rules_intro.html
 Yahoo’s! Resource on the subject:
http://developer.yahoo.com/performance/rules.html
 Has anyone done any of this “Page Speed” stuff before? With
Overview
 Make Fewer HTTP Requests
 Combine CSS & JS into as few files as possible.
 Enable Drupal options from performance page.
 Create sprite images for layout elements and implement using CSS.
 Enable Progressive Page Load and Remove Unused Markup
 Put the $scripts at the bottom of the template, right above $closure.
 Remove unused CSS and JavaScript being added by core modules.
 Externalize, Minify, and What to Avoid
 Make JavaScript and CSS External.
 Minify JavaScript & CSS.
 Avoid CSS Expressions.
 Avoid bad requests or redirects.
 Use a Content Delivery Network
 Fake CDN using CDN module.
 Setting up Cookie Domain
 Defined in: sites/default/settings.php
 Needs to be different from the sub-domains being used to serve static files through the CDN module.
 Configure Headers and Compression
 Add an Expires Header.
 Gzip Components.
 Configure ETags.
Overview
 80% of the time it takes for a
web page to load is on the
client side.
 Using all the tips in this
presentation should cut 25%
to 50% off the load time of
optimized page requests.
 Drupal (6 or 7) can be used
to, fairly easily, implement a
whole bunch of these “front-
end performance” upgrades,
and knock a ton of errors off
of the Yahoo! and Google
speed-checker tools
validation checklists.
Get firebug first.
Make Fewer HTTP Requests
 Combine CSS & JS into as few files as possible.
Enable Drupal options “Optimize CSS files” and “Optimize JS files” from performance page:
/admin/settings/performance – Then clear cache and check front end to check there are no errors
and/or all files have been combined. If you added external css/js calls to your template, move them
into your-theme.info so they will be aggregated with the rest of the internal resources.
 Create sprite images for layout elements and
implement using CSS.
This means you will try to combine all your “layout images” into one file and modify the CSS to only
display the correct piece of the sprite in each element.
You should also make sure that from your CSS the sprite is only called one time, as a background
image, in a catch-all rule for all the elements that use it.
Use this module to cheat (pass the validation checks in the tools without doing much work):
http://drupal.org/project/css_emimage
Remove extra CSS & put JS at the bottom
 Remove Unused CSS
 Lots of CSS is added by core modules, you can strip it out by finding/adding this function in your themes template.php file:
 phptemplate_preprocess_page
 The needed code: http://drupalbin.com/19830
 Test to make sure each file excluded is not one needed for some layout element or whatever to display.
 Disable “Optimize CSS files” option on the performance page and run the Google tool. Look at the very bottom, it will show you “unused
CSS” and point you to each file. This allows cherry picking the required CSS over into a “theme style sheet”, so the original file can be
excluded from template.php, and our page will still be just as pretty as ever:)
 CSS at the Top and JS at the Bottom - Progressive Page Loading
 In most themes this means moving: <?php print $scripts; ?> to the bottom, of the template file. right above: <?php print $closure; ?>.
 If a module is printing its own JS in the head: find “drupal_add_js” in that module directory and change it’s scope to “footer”:
 drupal_add_js($data = NULL, $type = 'module', $scope = ‘footer', $defer = FALSE, $cache = TRUE, $preprocess = TRUE);
 This breaks some JavaScripts!
 For an idea of how to re-make document-write’s (so they work when loading last) take a look at the “DOM element replace” post-
doc write scripts - at the bottom of this document.
 Move it to the bottom, save, clear your cache, then make sure that all your JavaScript is still working correctly and no errors are being
produced.
 If nothing breaks, you have enabled progressive page loading!
 As soon as an element is read by the browser: it is rendered, styled, to the user, element by element, down the page.
 If JavaScript is left at the top nothing can download or render on the page until all of the JS in the head is finished being processed, lame.
More CSS & JS Cleanup
 Avoid CSS Expressions
Yahoo! Says it best: CSS expressions are a powerful (and dangerous) way to set CSS properties
dynamically. They were supported in Internet Explorer starting with version 5, but were deprecated
starting with IE8. As an example, the background color could be set to alternate every hour using
CSS expressions:
background-color: expression( (new Date()).getHours()%2 ? "#B8D4FF" : "#F08A00" );
 Make JavaScript and CSS External
This way they don’t need to be loaded with the HTML on every page. Once the document is
cached on the client side it will not need to reload and won’t be getting sent out with every request
like it would if it were embedded.
 Minify JavaScript.
This module can be used in D6 to minify JavaScript using JSMin:
http://drupal.org/project/javascript_aggregator I cannot find a working D7 solution, and it’s not in core.
There is something similar for CSS Gzip:
http://drupal.org/project/css_gzip D7 has this in core.
If your using private downloads:
Gzipping of js & css can be achieved with the Boost module.
 Fix bad Requests and/or Redirects
Make sure external resources being used on the page (js, css, images, flash, ect.) are not
missing and are not being redirected to other resources to load. So, you don’t want your
image: www.mysite.com/image.jpg redirecting to static.mysite.com/image.jpg before loading, you
want to just link the img src to: static.mysite.com/image.jpg in the first place.
Use a Content Delivery Network
 If your site is not big enough to require an actual content delivery network:
This is how to set up a fake one to allow resources to download in parallel off of sub-
domains.
 Most browsers, by default, only download two resources from one domain at a time
(only one at a time for JS). Spreading static resources (like images, CSS, and JS)
across couple of sub-domains will allow browsers to download things, 2 at a time, from
each domain simultaneously.
 I recommend starting by adding only one sub-domain for this (most sites do not
require separate ones for css, js, and images) I used this one on my site:
http://static.plattdaddy.com
 Create the sub-domain pointing to the root of your existing website.
Once this is finished you should be able to access your exact site through either domain: static. = www.
As long as there’s nothing in .htaccess trying to redirect you back to www or something.
 Install the CDN Module: http://drupal.org/project/cdn
In D6 you’ll have to patch core (possibly twice) just like it says in the readme.txt.
 Configure the “Fake CDN”: /admin/settings/cdn/details
Add rule: http://static.yourwebsite.com|.jpg .jpeg .gif .png .ico .png .js .css
 Enable the “Fake CDN”: /admin/settings/cdn
Leave the default “mode” selected: Origin Pull.
 Make sure to add some redirect rules like this to your .htaccess file so you don’t create a
ton of nasty duplicate content and canonical domain confusion issues in the search
engines.
Setting up cookie domain
 A domain that sets a cookie is considered a “cookie enabled domain” by whatever requests it. The
goal here is to separate static resources onto a domain that dose not set any cookies first we’ll
need to set which domain we want Drupal to use for setting cookies, usually this will be www.
If you must have your cookie domain set to the root of your site, like this: http://plattdaddy.com,
then you should serve static resources from a separate domain, like yimg.com for Yahoo and
ytimg.com for Youtube.
 You’ll need something like this cookie viewer add-on for FireFox (right click any page, click “more
info” then click the cookies tab), so you can see, really clearly, what cookies have been loaded, and
from what domain. I also recommend using the clear cache button add-on while testing your cookie
domain setup.
 In settings.php uncomment this line and put your domain in like this:
$cookie_domain = 'www.yourwebsite.com';
 If you use Google Analytics
The cookies that provides is via *.example.com – so, as per their tutorial page, you’ll *have to* use a separate
domain name for static files if you want to keep it cookie-free (at least pre-asynchronous tracking anyway).
The way, I found, around this one is to add this to the analytics code:
_gaq.push(["_setDomainName", "www.plattdaddy.com"]);
If your using the GA module:
Go to: admin/settings/googleanalytics and just add the above snippet to the “Custom JavaScript code” area on the
admin page.
 If you have enabled the CDN
The static resources will already be getting served off one or more custom sub-domains.
So, now, your site should pass either tools validation tests for serving static content off of cookie-
less domains and parallelizing downloads across hostnames.
Configure Headers and Compression
 Expires Header
Make sure the expires apache module us loaded. If not, uncomment this in httpd.conf (then restart
apache):
LoadModule expires_module modules/mod_expires.so
 Gzip Components
Make sure the deflate apache module us loaded. If not, uncomment this in httpd.conf (then restart
apache):
LoadModule deflate_module modules/mod_deflate.so
 Configure E-tags
If mod_expires is on: add FileETag MTime Size inside of:
<IfModule mod_expires.c>
 Copy all of the needed customizations from this example: http://drupalbin.com/19839
 You’ll need to transfer to your sites .htaccess file:
 The second and third: <FilesMatch></FilesMatch>’s
Place these directly below the default one, like I have it in the example.
 The entire: <IfModule mod_expires.c></IfModule>

Más contenido relacionado

La actualidad más candente

Godefroid Chapelle Ajax With Plone 3 Kss Development Patterns
Godefroid Chapelle   Ajax With Plone 3   Kss Development PatternsGodefroid Chapelle   Ajax With Plone 3   Kss Development Patterns
Godefroid Chapelle Ajax With Plone 3 Kss Development PatternsVincenzo Barone
 
Pagespeed what, why, and how it works
Pagespeed   what, why, and how it worksPagespeed   what, why, and how it works
Pagespeed what, why, and how it worksIlya Grigorik
 
How to investigate and recover from a security breach in WordPress
How to investigate and recover from a security breach in WordPressHow to investigate and recover from a security breach in WordPress
How to investigate and recover from a security breach in WordPressOtto Kekäläinen
 
A web perf dashboard up & running in 90 minutes presentation
A web perf dashboard up & running in 90 minutes presentationA web perf dashboard up & running in 90 minutes presentation
A web perf dashboard up & running in 90 minutes presentationJustin Dorfman
 
BaláZs Ree Introduction To Kss, Kinetic Style Sheets
BaláZs Ree   Introduction To Kss, Kinetic Style SheetsBaláZs Ree   Introduction To Kss, Kinetic Style Sheets
BaláZs Ree Introduction To Kss, Kinetic Style SheetsVincenzo Barone
 
Build Better Responsive websites. Hrvoje Jurišić
Build Better Responsive websites. Hrvoje JurišićBuild Better Responsive websites. Hrvoje Jurišić
Build Better Responsive websites. Hrvoje JurišićMeetMagentoNY2014
 
HTML5: friend or foe (to Flash)?
HTML5: friend or foe (to Flash)?HTML5: friend or foe (to Flash)?
HTML5: friend or foe (to Flash)?Remy Sharp
 
Administer WordPress with WP-CLI
Administer WordPress with WP-CLIAdminister WordPress with WP-CLI
Administer WordPress with WP-CLISuwash Kunwar
 
AD1387: Outside The Box: Integrating with Non-Domino Apps using XPages and Ja...
AD1387: Outside The Box: Integrating with Non-Domino Apps using XPages and Ja...AD1387: Outside The Box: Integrating with Non-Domino Apps using XPages and Ja...
AD1387: Outside The Box: Integrating with Non-Domino Apps using XPages and Ja...panagenda
 
Building an HTML5 Video Player
Building an HTML5 Video PlayerBuilding an HTML5 Video Player
Building an HTML5 Video PlayerJim Jeffers
 
Realize mais com HTML 5 e CSS 3 - 16 EDTED - RJ
Realize mais com HTML 5 e CSS 3 - 16 EDTED - RJRealize mais com HTML 5 e CSS 3 - 16 EDTED - RJ
Realize mais com HTML 5 e CSS 3 - 16 EDTED - RJLeonardo Balter
 
Scaling Drupal: Not IF... HOW
Scaling Drupal: Not IF... HOWScaling Drupal: Not IF... HOW
Scaling Drupal: Not IF... HOWTreehouse Agency
 
Web Page Test - Beyond the Basics
Web Page Test - Beyond the BasicsWeb Page Test - Beyond the Basics
Web Page Test - Beyond the BasicsAndy Davies
 
JavaScript performance patterns
JavaScript performance patternsJavaScript performance patterns
JavaScript performance patternsStoyan Stefanov
 

La actualidad más candente (20)

Godefroid Chapelle Ajax With Plone 3 Kss Development Patterns
Godefroid Chapelle   Ajax With Plone 3   Kss Development PatternsGodefroid Chapelle   Ajax With Plone 3   Kss Development Patterns
Godefroid Chapelle Ajax With Plone 3 Kss Development Patterns
 
Pagespeed what, why, and how it works
Pagespeed   what, why, and how it worksPagespeed   what, why, and how it works
Pagespeed what, why, and how it works
 
How to investigate and recover from a security breach in WordPress
How to investigate and recover from a security breach in WordPressHow to investigate and recover from a security breach in WordPress
How to investigate and recover from a security breach in WordPress
 
A web perf dashboard up & running in 90 minutes presentation
A web perf dashboard up & running in 90 minutes presentationA web perf dashboard up & running in 90 minutes presentation
A web perf dashboard up & running in 90 minutes presentation
 
HTML 5 - Overview
HTML 5 - OverviewHTML 5 - Overview
HTML 5 - Overview
 
YSlow 2.0
YSlow 2.0YSlow 2.0
YSlow 2.0
 
BaláZs Ree Introduction To Kss, Kinetic Style Sheets
BaláZs Ree   Introduction To Kss, Kinetic Style SheetsBaláZs Ree   Introduction To Kss, Kinetic Style Sheets
BaláZs Ree Introduction To Kss, Kinetic Style Sheets
 
Build Better Responsive websites. Hrvoje Jurišić
Build Better Responsive websites. Hrvoje JurišićBuild Better Responsive websites. Hrvoje Jurišić
Build Better Responsive websites. Hrvoje Jurišić
 
Nodejs.meetup
Nodejs.meetupNodejs.meetup
Nodejs.meetup
 
WordPress and Ajax
WordPress and AjaxWordPress and Ajax
WordPress and Ajax
 
HTML5: friend or foe (to Flash)?
HTML5: friend or foe (to Flash)?HTML5: friend or foe (to Flash)?
HTML5: friend or foe (to Flash)?
 
Liking performance
Liking performanceLiking performance
Liking performance
 
Administer WordPress with WP-CLI
Administer WordPress with WP-CLIAdminister WordPress with WP-CLI
Administer WordPress with WP-CLI
 
AD1387: Outside The Box: Integrating with Non-Domino Apps using XPages and Ja...
AD1387: Outside The Box: Integrating with Non-Domino Apps using XPages and Ja...AD1387: Outside The Box: Integrating with Non-Domino Apps using XPages and Ja...
AD1387: Outside The Box: Integrating with Non-Domino Apps using XPages and Ja...
 
Building an HTML5 Video Player
Building an HTML5 Video PlayerBuilding an HTML5 Video Player
Building an HTML5 Video Player
 
Realize mais com HTML 5 e CSS 3 - 16 EDTED - RJ
Realize mais com HTML 5 e CSS 3 - 16 EDTED - RJRealize mais com HTML 5 e CSS 3 - 16 EDTED - RJ
Realize mais com HTML 5 e CSS 3 - 16 EDTED - RJ
 
Scaling Drupal: Not IF... HOW
Scaling Drupal: Not IF... HOWScaling Drupal: Not IF... HOW
Scaling Drupal: Not IF... HOW
 
Web Page Test - Beyond the Basics
Web Page Test - Beyond the BasicsWeb Page Test - Beyond the Basics
Web Page Test - Beyond the Basics
 
Os Pruett
Os PruettOs Pruett
Os Pruett
 
JavaScript performance patterns
JavaScript performance patternsJavaScript performance patterns
JavaScript performance patterns
 

Destacado

Cloud Connect Santa Clara 2013: Web Acceleration and Front-End Optimization (...
Cloud Connect Santa Clara 2013: Web Acceleration and Front-End Optimization (...Cloud Connect Santa Clara 2013: Web Acceleration and Front-End Optimization (...
Cloud Connect Santa Clara 2013: Web Acceleration and Front-End Optimization (...Strangeloop
 
Front end optimization
Front end optimizationFront end optimization
Front end optimizationAbhishek Anand
 
Front-End Performance Optimization in WordPress
Front-End Performance Optimization in WordPressFront-End Performance Optimization in WordPress
Front-End Performance Optimization in WordPressdrywallbmb
 
Marrying CDNs with Front-End Optimization
Marrying CDNs with Front-End Optimization Marrying CDNs with Front-End Optimization
Marrying CDNs with Front-End Optimization Strangeloop
 
Heavy Web Optimization: Frontend
Heavy Web Optimization: FrontendHeavy Web Optimization: Frontend
Heavy Web Optimization: FrontendVõ Duy Tuấn
 

Destacado (7)

Cloud Connect Santa Clara 2013: Web Acceleration and Front-End Optimization (...
Cloud Connect Santa Clara 2013: Web Acceleration and Front-End Optimization (...Cloud Connect Santa Clara 2013: Web Acceleration and Front-End Optimization (...
Cloud Connect Santa Clara 2013: Web Acceleration and Front-End Optimization (...
 
Front end optimization
Front end optimizationFront end optimization
Front end optimization
 
Front-End Performance Optimization in WordPress
Front-End Performance Optimization in WordPressFront-End Performance Optimization in WordPress
Front-End Performance Optimization in WordPress
 
Front-End Optimization (FEO)
Front-End Optimization (FEO)Front-End Optimization (FEO)
Front-End Optimization (FEO)
 
Marrying CDNs with Front-End Optimization
Marrying CDNs with Front-End Optimization Marrying CDNs with Front-End Optimization
Marrying CDNs with Front-End Optimization
 
Heavy Web Optimization: Frontend
Heavy Web Optimization: FrontendHeavy Web Optimization: Frontend
Heavy Web Optimization: Frontend
 
Image processing ppt
Image processing pptImage processing ppt
Image processing ppt
 

Similar a Front end performance optimization

Drupal Frontend Performance and Scalability
Drupal Frontend Performance and ScalabilityDrupal Frontend Performance and Scalability
Drupal Frontend Performance and ScalabilityAshok Modi
 
DrupalCampLA 2011 - Drupal frontend-optimizing
DrupalCampLA 2011 - Drupal frontend-optimizingDrupalCampLA 2011 - Drupal frontend-optimizing
DrupalCampLA 2011 - Drupal frontend-optimizingAshok Modi
 
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
 
Magento Performance Optimization 101
Magento Performance Optimization 101Magento Performance Optimization 101
Magento Performance Optimization 101Angus Li
 
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 practicesStoyan Stefanov
 
Improving Drupal Performances
Improving Drupal PerformancesImproving Drupal Performances
Improving Drupal PerformancesVladimir Ilic
 
Building high performance web apps.
Building high performance web apps.Building high performance web apps.
Building high performance web apps.Arshak Movsisyan
 
Drupal Theme Development - DrupalCon Chicago 2011
Drupal Theme Development - DrupalCon Chicago 2011Drupal Theme Development - DrupalCon Chicago 2011
Drupal Theme Development - DrupalCon Chicago 2011Ryan Price
 
The Need for Speed (5 Performance Optimization Tipps) - brightonSEO 2014
The Need for Speed (5 Performance Optimization Tipps) - brightonSEO 2014The Need for Speed (5 Performance Optimization Tipps) - brightonSEO 2014
The Need for Speed (5 Performance Optimization Tipps) - brightonSEO 2014Bastian Grimm
 
So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017
So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017 So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017
So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017 Evan Mullins
 
Introduction to BOOTSTRAP
Introduction to BOOTSTRAPIntroduction to BOOTSTRAP
Introduction to BOOTSTRAPJeanie Arnoco
 
Customizing WordPress Themes
Customizing WordPress ThemesCustomizing WordPress Themes
Customizing WordPress ThemesLaura Hartwig
 
The new static resources framework
The new static resources frameworkThe new static resources framework
The new static resources frameworkmarcplmer
 
Installing And Configuration for your Wordpress blog
Installing And Configuration for your Wordpress blogInstalling And Configuration for your Wordpress blog
Installing And Configuration for your Wordpress blogigorgentry
 
Building Performance - ein Frontend-Build-Prozess für Java mit Maven
Building Performance - ein Frontend-Build-Prozess für Java mit MavenBuilding Performance - ein Frontend-Build-Prozess für Java mit Maven
Building Performance - ein Frontend-Build-Prozess für Java mit MavenOliver Ochs
 
Frontend performance
Frontend performanceFrontend performance
Frontend performancesacred 8
 
Twitter bootstrap training_session_ppt
Twitter bootstrap training_session_pptTwitter bootstrap training_session_ppt
Twitter bootstrap training_session_pptRadheshyam Kori
 
Web development today
Web development todayWeb development today
Web development todayJaydev Gajera
 

Similar a Front end performance optimization (20)

Drupal Frontend Performance and Scalability
Drupal Frontend Performance and ScalabilityDrupal Frontend Performance and Scalability
Drupal Frontend Performance and Scalability
 
DrupalCampLA 2011 - Drupal frontend-optimizing
DrupalCampLA 2011 - Drupal frontend-optimizingDrupalCampLA 2011 - Drupal frontend-optimizing
DrupalCampLA 2011 - Drupal frontend-optimizing
 
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
 
Magento Performance Optimization 101
Magento Performance Optimization 101Magento Performance Optimization 101
Magento Performance Optimization 101
 
Web technologies part-2
Web technologies part-2Web technologies part-2
Web technologies part-2
 
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
 
Improving Drupal Performances
Improving Drupal PerformancesImproving Drupal Performances
Improving Drupal Performances
 
Html5 & less css
Html5 & less cssHtml5 & less css
Html5 & less css
 
Building high performance web apps.
Building high performance web apps.Building high performance web apps.
Building high performance web apps.
 
Drupal Theme Development - DrupalCon Chicago 2011
Drupal Theme Development - DrupalCon Chicago 2011Drupal Theme Development - DrupalCon Chicago 2011
Drupal Theme Development - DrupalCon Chicago 2011
 
The Need for Speed (5 Performance Optimization Tipps) - brightonSEO 2014
The Need for Speed (5 Performance Optimization Tipps) - brightonSEO 2014The Need for Speed (5 Performance Optimization Tipps) - brightonSEO 2014
The Need for Speed (5 Performance Optimization Tipps) - brightonSEO 2014
 
So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017
So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017 So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017
So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017
 
Introduction to BOOTSTRAP
Introduction to BOOTSTRAPIntroduction to BOOTSTRAP
Introduction to BOOTSTRAP
 
Customizing WordPress Themes
Customizing WordPress ThemesCustomizing WordPress Themes
Customizing WordPress Themes
 
The new static resources framework
The new static resources frameworkThe new static resources framework
The new static resources framework
 
Installing And Configuration for your Wordpress blog
Installing And Configuration for your Wordpress blogInstalling And Configuration for your Wordpress blog
Installing And Configuration for your Wordpress blog
 
Building Performance - ein Frontend-Build-Prozess für Java mit Maven
Building Performance - ein Frontend-Build-Prozess für Java mit MavenBuilding Performance - ein Frontend-Build-Prozess für Java mit Maven
Building Performance - ein Frontend-Build-Prozess für Java mit Maven
 
Frontend performance
Frontend performanceFrontend performance
Frontend performance
 
Twitter bootstrap training_session_ppt
Twitter bootstrap training_session_pptTwitter bootstrap training_session_ppt
Twitter bootstrap training_session_ppt
 
Web development today
Web development todayWeb development today
Web development today
 

Último

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 

Último (20)

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 

Front end performance optimization

  • 1. Front-end Performance Optimization Using Drupal Fixing all validation errors reported by the Yslow & Page Speed tools.
  • 2. Introduction  The performance-enhancing concepts that guide this presentation I first found outlined in these two books:  High Performance Websites http://www.amazon.com/High-Performance-Web-Sites-Essential/dp/0596529309  Even Faster Websites http://www.amazon.com/Even-Faster-Web-Sites-Performance/dp/0596522304/  It’s best to use both the Google and Yahoo! Page Speed Validation Tools - And try to comply with all of the suggestions they give:  Google’s Resource on the subject: http://code.google.com/speed/page-speed/docs/rules_intro.html  Yahoo’s! Resource on the subject: http://developer.yahoo.com/performance/rules.html  Has anyone done any of this “Page Speed” stuff before? With
  • 3. Overview  Make Fewer HTTP Requests  Combine CSS & JS into as few files as possible.  Enable Drupal options from performance page.  Create sprite images for layout elements and implement using CSS.  Enable Progressive Page Load and Remove Unused Markup  Put the $scripts at the bottom of the template, right above $closure.  Remove unused CSS and JavaScript being added by core modules.  Externalize, Minify, and What to Avoid  Make JavaScript and CSS External.  Minify JavaScript & CSS.  Avoid CSS Expressions.  Avoid bad requests or redirects.  Use a Content Delivery Network  Fake CDN using CDN module.  Setting up Cookie Domain  Defined in: sites/default/settings.php  Needs to be different from the sub-domains being used to serve static files through the CDN module.  Configure Headers and Compression  Add an Expires Header.  Gzip Components.  Configure ETags.
  • 4. Overview  80% of the time it takes for a web page to load is on the client side.  Using all the tips in this presentation should cut 25% to 50% off the load time of optimized page requests.  Drupal (6 or 7) can be used to, fairly easily, implement a whole bunch of these “front- end performance” upgrades, and knock a ton of errors off of the Yahoo! and Google speed-checker tools validation checklists. Get firebug first.
  • 5. Make Fewer HTTP Requests  Combine CSS & JS into as few files as possible. Enable Drupal options “Optimize CSS files” and “Optimize JS files” from performance page: /admin/settings/performance – Then clear cache and check front end to check there are no errors and/or all files have been combined. If you added external css/js calls to your template, move them into your-theme.info so they will be aggregated with the rest of the internal resources.  Create sprite images for layout elements and implement using CSS. This means you will try to combine all your “layout images” into one file and modify the CSS to only display the correct piece of the sprite in each element. You should also make sure that from your CSS the sprite is only called one time, as a background image, in a catch-all rule for all the elements that use it. Use this module to cheat (pass the validation checks in the tools without doing much work): http://drupal.org/project/css_emimage
  • 6. Remove extra CSS & put JS at the bottom  Remove Unused CSS  Lots of CSS is added by core modules, you can strip it out by finding/adding this function in your themes template.php file:  phptemplate_preprocess_page  The needed code: http://drupalbin.com/19830  Test to make sure each file excluded is not one needed for some layout element or whatever to display.  Disable “Optimize CSS files” option on the performance page and run the Google tool. Look at the very bottom, it will show you “unused CSS” and point you to each file. This allows cherry picking the required CSS over into a “theme style sheet”, so the original file can be excluded from template.php, and our page will still be just as pretty as ever:)  CSS at the Top and JS at the Bottom - Progressive Page Loading  In most themes this means moving: <?php print $scripts; ?> to the bottom, of the template file. right above: <?php print $closure; ?>.  If a module is printing its own JS in the head: find “drupal_add_js” in that module directory and change it’s scope to “footer”:  drupal_add_js($data = NULL, $type = 'module', $scope = ‘footer', $defer = FALSE, $cache = TRUE, $preprocess = TRUE);  This breaks some JavaScripts!  For an idea of how to re-make document-write’s (so they work when loading last) take a look at the “DOM element replace” post- doc write scripts - at the bottom of this document.  Move it to the bottom, save, clear your cache, then make sure that all your JavaScript is still working correctly and no errors are being produced.  If nothing breaks, you have enabled progressive page loading!  As soon as an element is read by the browser: it is rendered, styled, to the user, element by element, down the page.  If JavaScript is left at the top nothing can download or render on the page until all of the JS in the head is finished being processed, lame.
  • 7. More CSS & JS Cleanup  Avoid CSS Expressions Yahoo! Says it best: CSS expressions are a powerful (and dangerous) way to set CSS properties dynamically. They were supported in Internet Explorer starting with version 5, but were deprecated starting with IE8. As an example, the background color could be set to alternate every hour using CSS expressions: background-color: expression( (new Date()).getHours()%2 ? "#B8D4FF" : "#F08A00" );  Make JavaScript and CSS External This way they don’t need to be loaded with the HTML on every page. Once the document is cached on the client side it will not need to reload and won’t be getting sent out with every request like it would if it were embedded.  Minify JavaScript. This module can be used in D6 to minify JavaScript using JSMin: http://drupal.org/project/javascript_aggregator I cannot find a working D7 solution, and it’s not in core. There is something similar for CSS Gzip: http://drupal.org/project/css_gzip D7 has this in core. If your using private downloads: Gzipping of js & css can be achieved with the Boost module.  Fix bad Requests and/or Redirects Make sure external resources being used on the page (js, css, images, flash, ect.) are not missing and are not being redirected to other resources to load. So, you don’t want your image: www.mysite.com/image.jpg redirecting to static.mysite.com/image.jpg before loading, you want to just link the img src to: static.mysite.com/image.jpg in the first place.
  • 8. Use a Content Delivery Network  If your site is not big enough to require an actual content delivery network: This is how to set up a fake one to allow resources to download in parallel off of sub- domains.  Most browsers, by default, only download two resources from one domain at a time (only one at a time for JS). Spreading static resources (like images, CSS, and JS) across couple of sub-domains will allow browsers to download things, 2 at a time, from each domain simultaneously.  I recommend starting by adding only one sub-domain for this (most sites do not require separate ones for css, js, and images) I used this one on my site: http://static.plattdaddy.com  Create the sub-domain pointing to the root of your existing website. Once this is finished you should be able to access your exact site through either domain: static. = www. As long as there’s nothing in .htaccess trying to redirect you back to www or something.  Install the CDN Module: http://drupal.org/project/cdn In D6 you’ll have to patch core (possibly twice) just like it says in the readme.txt.  Configure the “Fake CDN”: /admin/settings/cdn/details Add rule: http://static.yourwebsite.com|.jpg .jpeg .gif .png .ico .png .js .css  Enable the “Fake CDN”: /admin/settings/cdn Leave the default “mode” selected: Origin Pull.  Make sure to add some redirect rules like this to your .htaccess file so you don’t create a ton of nasty duplicate content and canonical domain confusion issues in the search engines.
  • 9. Setting up cookie domain  A domain that sets a cookie is considered a “cookie enabled domain” by whatever requests it. The goal here is to separate static resources onto a domain that dose not set any cookies first we’ll need to set which domain we want Drupal to use for setting cookies, usually this will be www. If you must have your cookie domain set to the root of your site, like this: http://plattdaddy.com, then you should serve static resources from a separate domain, like yimg.com for Yahoo and ytimg.com for Youtube.  You’ll need something like this cookie viewer add-on for FireFox (right click any page, click “more info” then click the cookies tab), so you can see, really clearly, what cookies have been loaded, and from what domain. I also recommend using the clear cache button add-on while testing your cookie domain setup.  In settings.php uncomment this line and put your domain in like this: $cookie_domain = 'www.yourwebsite.com';  If you use Google Analytics The cookies that provides is via *.example.com – so, as per their tutorial page, you’ll *have to* use a separate domain name for static files if you want to keep it cookie-free (at least pre-asynchronous tracking anyway). The way, I found, around this one is to add this to the analytics code: _gaq.push(["_setDomainName", "www.plattdaddy.com"]); If your using the GA module: Go to: admin/settings/googleanalytics and just add the above snippet to the “Custom JavaScript code” area on the admin page.  If you have enabled the CDN The static resources will already be getting served off one or more custom sub-domains. So, now, your site should pass either tools validation tests for serving static content off of cookie- less domains and parallelizing downloads across hostnames.
  • 10. Configure Headers and Compression  Expires Header Make sure the expires apache module us loaded. If not, uncomment this in httpd.conf (then restart apache): LoadModule expires_module modules/mod_expires.so  Gzip Components Make sure the deflate apache module us loaded. If not, uncomment this in httpd.conf (then restart apache): LoadModule deflate_module modules/mod_deflate.so  Configure E-tags If mod_expires is on: add FileETag MTime Size inside of: <IfModule mod_expires.c>  Copy all of the needed customizations from this example: http://drupalbin.com/19839  You’ll need to transfer to your sites .htaccess file:  The second and third: <FilesMatch></FilesMatch>’s Place these directly below the default one, like I have it in the example.  The entire: <IfModule mod_expires.c></IfModule>