SlideShare ist ein Scribd-Unternehmen logo
1 von 16
25 april
2013Front-end performance
Waarom focus op front-end?
• De meeste rendertijd gebeurt
in de front-end (JavaScript, CSS3)
• Google:
100 ms = 10% minder traffic,
500 ms = 20% minder traffic
• Amazon: elke 100ms trager = 1% minder sales
• Google rankt snelle sites hoger
De basics
• Minder requests
CSS / JS aggregatie & Image sprites
• Minder code
Minify (JSHint, Speedy module) & verwijder ongebruikte CSS / JS
• Minder data
Gzip compressie
• Gebruik een CDN (Content Delivery Network)
• Maximize browser caching (cache control directive)
• Stylesheets in head, JavaScript in footer (en geen inline)
Beginsituatie
• Geen caching
• Geen
compressie
• Veel resources
• 138 requests
87.3 KB, 2.63 s
Caching aanzetten helpt
• Caching
aanzetten
(settings.php)
• Al iets beter
121 requests
47.8 KB, 1.32 s
>
Minder CSS / JS
• Gebruik
hook_css_alter(
) en
hook_js_alter()
• Verwijder
ongebruikte
files
• Groepeer CSS
in dezelfde
groep
JavaScript naar de footer
Modernizr script in de header en zet de andere scripts in de footer (JS_DEFAULT).
function hero_js_alter(&$javascript) {
// Place the modernizr JS in the header, so the rest can be in the footer.
$modernizer_script = drupal_get_path('theme', 'hero') . '/js/foundation/modernizr.foundation.js';
$javascript[$modernizer_script]['in_header'] = TRUE;
foreach ($javascript as &$js) {
if ($js['in_header'] != TRUE && $js['type'] != 'inline') {
$js['group'] = JS_DEFAULT;
$js['scope'] = 'footer';
}
}
}
Requests verminderen met
sprites
• Elk ingredient
heeft een eigen
afbeelding. Dat
zijn al 39
requests.
Requests verminderen met
sprites
In plaats van veel losse afbeeldingen
1 grote afbeelding die alle afbeeldingen bevat
Voor:
a.button-add { background: url(button-add.png); }
a.button-add:hover { background: url(button-add-active.png); }
Na:
a.button-add { background: url(sprite.png); background-position: 0 0; }
a.button-add:hover { background-position: 0 50px; }
Spriting in Compass - SCSS
$ingredients-layout: horizontal;
@import "ingredients/*.png";
.product-ingredients-desktop > li {
@include ingredients-sprite('mango');
}
@each $ingredient in aardbeien, appel, banaan, etc {
&[data-id="#{$ingredient}"] {
@include ingredients-sprite-position("#{$ingredient}");
}
}
Spriting in Compass - CSS
.product-ingredients-desktop > li {
background: url('../images/ingredients-sa16d376cfe.png') no-repeat;
}
.product-ingredients-desktop > li {
background-position: -1750px 0;
}
.product-ingredients-desktop > li[data-id="aardbei"] {
background-position: -210px -5px;
}
.product-ingredients-desktop > li[data-id="appel"] {
background-position: -420px -5px;
}
.product-ingredients-desktop > li[data-id="banaan"] {
background-position: -630px -5px;
}
Spriting: het resultaat
• En weer iets sneller:
74 requests, 16.8 KB, 939 ms
Content Delivery Network
• Module: http://drupal.org/project/cdn
• Haal files van een server dichtbij
• Domein zet geen cookies (veel sneller)
• Veel minder requests op de webserver
75 requests, 25.0 KB, 962 ms
Nog twee tips
Specifieke selectors in CSS
.selector is sneller dan .body .page .selector
DOM aanpassen met jQuery is traag
Doe dit zo min mogelijk. Beter eerst je aanpassingen in JS doen en ineens
wegschrijven naar de DOM.
Leesvoer
• https://developers.google.com/speed/docs/best-practices/request
• http://www.sitepoint.com/web-site-optimization-steps/
• http://developer.yahoo.com/performance/rules.html
• http://www.metaltoad.com/blog/drupal-7-taking-control-css-
and-js-aggregation
Vragen?
baris@limoengroen.nl | www.limoengroen.nl | 020 - 737 1880

Weitere ähnliche Inhalte

Andere mochten auch

Puglia indagine prova_scritta_matematica_2013
Puglia indagine prova_scritta_matematica_2013Puglia indagine prova_scritta_matematica_2013
Puglia indagine prova_scritta_matematica_2013Sicolo Francesco
 
SumitK's mobile app dev using drupal as base ststem
SumitK's mobile app dev using drupal as base ststemSumitK's mobile app dev using drupal as base ststem
SumitK's mobile app dev using drupal as base ststemSumit Kataria
 
Continuous Integration & Drupal
Continuous Integration & DrupalContinuous Integration & Drupal
Continuous Integration & DrupalLimoenGroen
 
Chuyên đề kim loại tác dụng với dung dịch muối
Chuyên đề kim loại tác dụng với dung dịch muốiChuyên đề kim loại tác dụng với dung dịch muối
Chuyên đề kim loại tác dụng với dung dịch muốiPhát Lê
 

Andere mochten auch (6)

Puglia indagine prova_scritta_matematica_2013
Puglia indagine prova_scritta_matematica_2013Puglia indagine prova_scritta_matematica_2013
Puglia indagine prova_scritta_matematica_2013
 
010 efesios
010 efesios010 efesios
010 efesios
 
Beijing 20083
Beijing 20083Beijing 20083
Beijing 20083
 
SumitK's mobile app dev using drupal as base ststem
SumitK's mobile app dev using drupal as base ststemSumitK's mobile app dev using drupal as base ststem
SumitK's mobile app dev using drupal as base ststem
 
Continuous Integration & Drupal
Continuous Integration & DrupalContinuous Integration & Drupal
Continuous Integration & Drupal
 
Chuyên đề kim loại tác dụng với dung dịch muối
Chuyên đề kim loại tác dụng với dung dịch muốiChuyên đề kim loại tác dụng với dung dịch muối
Chuyên đề kim loại tác dụng với dung dịch muối
 

Ähnlich wie Front-end Performance in Drupal

Best Practice: Joomla! templating
Best Practice: Joomla! templatingBest Practice: Joomla! templating
Best Practice: Joomla! templatingHans Kuijpers
 
Html5 jeugdwerknet
Html5 jeugdwerknetHtml5 jeugdwerknet
Html5 jeugdwerknetHans Rossel
 
Presentatie WordPress Theme Frameworks WordCamp NL 2010
Presentatie WordPress Theme Frameworks WordCamp NL 2010Presentatie WordPress Theme Frameworks WordCamp NL 2010
Presentatie WordPress Theme Frameworks WordCamp NL 2010Remkus de Vries
 
Projectpaas drupaljam 2013 rotterdam
Projectpaas drupaljam 2013 rotterdamProjectpaas drupaljam 2013 rotterdam
Projectpaas drupaljam 2013 rotterdamBert Boerland
 
CSS3 kleuren en border-radius
CSS3 kleuren en border-radiusCSS3 kleuren en border-radius
CSS3 kleuren en border-radiusThomas Byttebier
 
Joomla Website optimaliseren - jug073 augustus 2018
Joomla Website optimaliseren - jug073 augustus 2018Joomla Website optimaliseren - jug073 augustus 2018
Joomla Website optimaliseren - jug073 augustus 2018Hans Kuijpers
 
Presentatie drupal sass
Presentatie drupal sassPresentatie drupal sass
Presentatie drupal sassKees
 
Magento cursus: theme opzetten & beheren
Magento cursus: theme opzetten & beherenMagento cursus: theme opzetten & beheren
Magento cursus: theme opzetten & beherenMichel Doens
 
Cursus Zend Framework - 1
Cursus Zend Framework - 1Cursus Zend Framework - 1
Cursus Zend Framework - 1bartjeukendrup
 
SharePoint API Nightmares
SharePoint API NightmaresSharePoint API Nightmares
SharePoint API NightmaresSparked
 
Why Drupal Is So Slow
Why Drupal Is So SlowWhy Drupal Is So Slow
Why Drupal Is So SlowBert Boerland
 

Ähnlich wie Front-end Performance in Drupal (14)

Best Practice: Joomla! templating
Best Practice: Joomla! templatingBest Practice: Joomla! templating
Best Practice: Joomla! templating
 
Refresher HTML(5) and CSS(3) - CC FE & UX
Refresher HTML(5) and CSS(3) - CC FE & UXRefresher HTML(5) and CSS(3) - CC FE & UX
Refresher HTML(5) and CSS(3) - CC FE & UX
 
Html5 jeugdwerknet
Html5 jeugdwerknetHtml5 jeugdwerknet
Html5 jeugdwerknet
 
Presentatie WordPress Theme Frameworks WordCamp NL 2010
Presentatie WordPress Theme Frameworks WordCamp NL 2010Presentatie WordPress Theme Frameworks WordCamp NL 2010
Presentatie WordPress Theme Frameworks WordCamp NL 2010
 
Projectpaas drupaljam 2013 rotterdam
Projectpaas drupaljam 2013 rotterdamProjectpaas drupaljam 2013 rotterdam
Projectpaas drupaljam 2013 rotterdam
 
CSS3 kleuren en border-radius
CSS3 kleuren en border-radiusCSS3 kleuren en border-radius
CSS3 kleuren en border-radius
 
Speeding up WordPress
Speeding up WordPressSpeeding up WordPress
Speeding up WordPress
 
Joomla Website optimaliseren - jug073 augustus 2018
Joomla Website optimaliseren - jug073 augustus 2018Joomla Website optimaliseren - jug073 augustus 2018
Joomla Website optimaliseren - jug073 augustus 2018
 
Presentatie webrichtlijnen
Presentatie webrichtlijnenPresentatie webrichtlijnen
Presentatie webrichtlijnen
 
Presentatie drupal sass
Presentatie drupal sassPresentatie drupal sass
Presentatie drupal sass
 
Magento cursus: theme opzetten & beheren
Magento cursus: theme opzetten & beherenMagento cursus: theme opzetten & beheren
Magento cursus: theme opzetten & beheren
 
Cursus Zend Framework - 1
Cursus Zend Framework - 1Cursus Zend Framework - 1
Cursus Zend Framework - 1
 
SharePoint API Nightmares
SharePoint API NightmaresSharePoint API Nightmares
SharePoint API Nightmares
 
Why Drupal Is So Slow
Why Drupal Is So SlowWhy Drupal Is So Slow
Why Drupal Is So Slow
 

Mehr von LimoenGroen

Managing Drupal interface translation
Managing Drupal interface translationManaging Drupal interface translation
Managing Drupal interface translationLimoenGroen
 
Drupal Quick wins for an accessible website
Drupal Quick wins for an accessible websiteDrupal Quick wins for an accessible website
Drupal Quick wins for an accessible websiteLimoenGroen
 
Open drupal DrupalCamp Gent 2018
Open drupal DrupalCamp Gent 2018Open drupal DrupalCamp Gent 2018
Open drupal DrupalCamp Gent 2018LimoenGroen
 
24Kitchen, the no. 1 platform for food lovers (Showcase LimoenGroen)
24Kitchen, the no. 1 platform for food lovers (Showcase LimoenGroen)24Kitchen, the no. 1 platform for food lovers (Showcase LimoenGroen)
24Kitchen, the no. 1 platform for food lovers (Showcase LimoenGroen)LimoenGroen
 
The Myths, Musts and Migraines of Migrations - DrupalJam 2018
The Myths, Musts and Migraines of Migrations - DrupalJam 2018The Myths, Musts and Migraines of Migrations - DrupalJam 2018
The Myths, Musts and Migraines of Migrations - DrupalJam 2018LimoenGroen
 
Being a better mentor
Being a better mentorBeing a better mentor
Being a better mentorLimoenGroen
 

Mehr von LimoenGroen (6)

Managing Drupal interface translation
Managing Drupal interface translationManaging Drupal interface translation
Managing Drupal interface translation
 
Drupal Quick wins for an accessible website
Drupal Quick wins for an accessible websiteDrupal Quick wins for an accessible website
Drupal Quick wins for an accessible website
 
Open drupal DrupalCamp Gent 2018
Open drupal DrupalCamp Gent 2018Open drupal DrupalCamp Gent 2018
Open drupal DrupalCamp Gent 2018
 
24Kitchen, the no. 1 platform for food lovers (Showcase LimoenGroen)
24Kitchen, the no. 1 platform for food lovers (Showcase LimoenGroen)24Kitchen, the no. 1 platform for food lovers (Showcase LimoenGroen)
24Kitchen, the no. 1 platform for food lovers (Showcase LimoenGroen)
 
The Myths, Musts and Migraines of Migrations - DrupalJam 2018
The Myths, Musts and Migraines of Migrations - DrupalJam 2018The Myths, Musts and Migraines of Migrations - DrupalJam 2018
The Myths, Musts and Migraines of Migrations - DrupalJam 2018
 
Being a better mentor
Being a better mentorBeing a better mentor
Being a better mentor
 

Front-end Performance in Drupal

  • 2. Waarom focus op front-end? • De meeste rendertijd gebeurt in de front-end (JavaScript, CSS3) • Google: 100 ms = 10% minder traffic, 500 ms = 20% minder traffic • Amazon: elke 100ms trager = 1% minder sales • Google rankt snelle sites hoger
  • 3. De basics • Minder requests CSS / JS aggregatie & Image sprites • Minder code Minify (JSHint, Speedy module) & verwijder ongebruikte CSS / JS • Minder data Gzip compressie • Gebruik een CDN (Content Delivery Network) • Maximize browser caching (cache control directive) • Stylesheets in head, JavaScript in footer (en geen inline)
  • 4. Beginsituatie • Geen caching • Geen compressie • Veel resources • 138 requests 87.3 KB, 2.63 s
  • 5. Caching aanzetten helpt • Caching aanzetten (settings.php) • Al iets beter 121 requests 47.8 KB, 1.32 s >
  • 6. Minder CSS / JS • Gebruik hook_css_alter( ) en hook_js_alter() • Verwijder ongebruikte files • Groepeer CSS in dezelfde groep
  • 7. JavaScript naar de footer Modernizr script in de header en zet de andere scripts in de footer (JS_DEFAULT). function hero_js_alter(&$javascript) { // Place the modernizr JS in the header, so the rest can be in the footer. $modernizer_script = drupal_get_path('theme', 'hero') . '/js/foundation/modernizr.foundation.js'; $javascript[$modernizer_script]['in_header'] = TRUE; foreach ($javascript as &$js) { if ($js['in_header'] != TRUE && $js['type'] != 'inline') { $js['group'] = JS_DEFAULT; $js['scope'] = 'footer'; } } }
  • 8. Requests verminderen met sprites • Elk ingredient heeft een eigen afbeelding. Dat zijn al 39 requests.
  • 9. Requests verminderen met sprites In plaats van veel losse afbeeldingen 1 grote afbeelding die alle afbeeldingen bevat Voor: a.button-add { background: url(button-add.png); } a.button-add:hover { background: url(button-add-active.png); } Na: a.button-add { background: url(sprite.png); background-position: 0 0; } a.button-add:hover { background-position: 0 50px; }
  • 10. Spriting in Compass - SCSS $ingredients-layout: horizontal; @import "ingredients/*.png"; .product-ingredients-desktop > li { @include ingredients-sprite('mango'); } @each $ingredient in aardbeien, appel, banaan, etc { &[data-id="#{$ingredient}"] { @include ingredients-sprite-position("#{$ingredient}"); } }
  • 11. Spriting in Compass - CSS .product-ingredients-desktop > li { background: url('../images/ingredients-sa16d376cfe.png') no-repeat; } .product-ingredients-desktop > li { background-position: -1750px 0; } .product-ingredients-desktop > li[data-id="aardbei"] { background-position: -210px -5px; } .product-ingredients-desktop > li[data-id="appel"] { background-position: -420px -5px; } .product-ingredients-desktop > li[data-id="banaan"] { background-position: -630px -5px; }
  • 12. Spriting: het resultaat • En weer iets sneller: 74 requests, 16.8 KB, 939 ms
  • 13. Content Delivery Network • Module: http://drupal.org/project/cdn • Haal files van een server dichtbij • Domein zet geen cookies (veel sneller) • Veel minder requests op de webserver 75 requests, 25.0 KB, 962 ms
  • 14. Nog twee tips Specifieke selectors in CSS .selector is sneller dan .body .page .selector DOM aanpassen met jQuery is traag Doe dit zo min mogelijk. Beter eerst je aanpassingen in JS doen en ineens wegschrijven naar de DOM.
  • 15. Leesvoer • https://developers.google.com/speed/docs/best-practices/request • http://www.sitepoint.com/web-site-optimization-steps/ • http://developer.yahoo.com/performance/rules.html • http://www.metaltoad.com/blog/drupal-7-taking-control-css- and-js-aggregation

Hinweis der Redaktion

  1. Google sites gebruikt www.gstatic.com als cookieless domein, Yahoo! uses yimg.com, YouTube uses ytimg.com, Amazon uses images-amazon.com and so on.
  2. DEMO: Audit window tonen
  3. Door CSS en JS te comprimeren en caching aan te zetten: 121 ipv 138 requests en de helft minder data
  4. Gebruik onderstaande gegevens of laat uw visitekaartje achter.