SlideShare a Scribd company logo
Efficient theming
    for Drupal
About us

   @CedricS                •   Frontend Developers
   Cedric Spillebeen
                           •   Focus on Dev and UX
   @janyves                •   krimson.be
   Jan-yves Vanhaverbeke

   @elswens
   Els Wens
Agenda

•   Introduction
•   Optimal Design Input
•   From Design to Theme
•   Basic Frontend Performance
•   Questions?
Introduction

•   Drupal is a CMS.
•   Content-first approach.
•   Built by backend developers.

    “ The Views output contains a rich set of div
    tags allowing fine-grained CSS control over
    the output. ”
Introduction

•   Get optimal design input. (complete designs)
•   A way of working that leads to a Drupal
    theme that is flexible, maintainable and
    consistent.
•   Optimize the Frontend Performance.
Optimize design input
Problems with designs

•   A design is static but Drupal is flexible.
•   Not all pages will be designed.
•   Designs are rarely consistent.
•   A design reflects the ideal situation.
Solutions

•   Take out inconsistencies before the final
    delivery.
•   Check for feasibility.
•   Ask for a style guide.
Style guide

•   An overview of all recurring design elements.
•   A requirement for every CMS design.
•   A separate design with all elements in the
    site.
•   Leading in case of inconsistencies.
Style guide

•   Site elements:
    •   Navigations: including mouse-over and active states.

    •   One or more block templates.

    •   A pager.

    •   Message boxes: warning, confirmation and error.

    •   A form. Typically useful for the contact form.

    •   A list of the most important colors.
Style guide

•   Typography:
    •   Headings: H1, H2, H3 and H4.

    •   Links: color and (optional) underline. Also define a
        mouse-over state.

    •   Paragraph: for default text the line-height and space
        between text should be defined.

    •   Unordered list: How does an unordered list in content
        look?
From design to theme
Efficient theming in Drupal
Analyze the design

•   Print all designs.
•   Look for patterns:
    •   Image styles
    •   View Modes
•   Decide on HTML tags / classes / IDs
Optimize the HTML

•   Don’t just take what Drupal offers by default.
•   Case: Views + Panels + Display Suite.
Optimize the HTML

•   Don’t just take what Drupal offers by default.
•   Case: Views + Panels + Display Suite.
Optimize the HTML

•   Don’t just take what Drupal offers by default.
•   Case: Views + Panels + Display Suite.
Optimize the HTML

•   Don’t just take what Drupal offers by default.
•   Case: Views + Panels + Display Suite.
•   Use generic classes above IDs.
•   Replace module specific HTML.
First step

•   Get the basics right first!
•   Add a simple page with mixed typographical
    content.
•   Style all generic elements: header, footer,
    navigation, typography, colors, links etc.
Keep your CSS flexible

•   Work as generic as possible.


    .field
     vs
    .page-article #content
    div.node div.field-title
Keep your CSS flexible

•   Theme a visual element, not a Drupal
    module:


    .article-teaser
     vs
    .views-articles .views-
    row
Keep your CSS flexible

•   Dare to rework existing CSS as features are
    added.
Optimize your CSS

•   Remove Drupal and module CSS (see
    Frontend Performance).
•   Use Drupal CSS standards: http://drupal.org/
    node/302199
•   Use comments to add structure to your CSS.
    /*
     * Navigation
     */

    /* Sidebar Navigation */
Frontend Performance
Reduce download size

•   Clean up your HTML.
•   Gzip compression for HTML.
•   mod_expires in Apache.
•   Optimize your images: http://drupal.org/
    project/imageapi_optimize.
•   Use Image Styles and Image Resize Filter.
Reduce download size

•   Remove unused Drupal and module CSS
    and javascript:
    •   hook_css_alter()
    •   hook_js_alter()
•   Add page specific CSS and javascript:
    •   drupal_add_css()
    •   drupal_add_js()
Less HTTP requests

         •   Aggregate CSS and javascript.
         •   Combine different groups into one:
/**                                              /**
  * Implements hook_js_alter().                    * Implements hook_css_alter().
  */                                               */
function mymodule_js_alter(&$javascript) {       function mymodule_css_alter(&$css) {
   uasort($javascript, 'drupal_sort_css_js');       uasort($css, 'drupal_sort_css_js');
   $i = 0;                                          $i = 0;
   foreach ($javascript as $name => $script) {      foreach ($css as $name => $style) {
     $javascript[$name]['weight'] = $i++;             $css[$name]['weight'] = $i++;
     $javascript[$name]['group'] = JS_DEFAULT;        $css[$name]['group'] = CSS_DEFAULT;
     $javascript[$name]['every_page'] = FALSE;        $css[$name]['every_page'] = FALSE;
   }                                                }
}                                                }
Other

•   Move JS to the bottom in your html.tpl.php.
•   Use a CDN: http://drupal.org/project/cdn.
•   Test your site with Yslow.
Questions?

More Related Content

PDF
Minimalist Theming: How to Build a Lean, Mean Drupal 8 Theme
PDF
The web context
PPT
Creating Responsive Drupal Sites with Zen Grids and the Zen 5 Theme
PDF
Using Core Themes in Drupal 8
PPTX
BDUG Responsive Web Theming - 7/23/12
PPTX
Hammersmith fundamentals html fundamentals
PPTX
.Less - CSS done right
PPTX
Drupal Camp Manila 2014 - Theming with Zen
Minimalist Theming: How to Build a Lean, Mean Drupal 8 Theme
The web context
Creating Responsive Drupal Sites with Zen Grids and the Zen 5 Theme
Using Core Themes in Drupal 8
BDUG Responsive Web Theming - 7/23/12
Hammersmith fundamentals html fundamentals
.Less - CSS done right
Drupal Camp Manila 2014 - Theming with Zen

What's hot (20)

PPTX
Basics of Front End Web Dev PowerPoint
ODP
Drupal distributions - how to build them
PPTX
Introduction to Custom WordPress Themeing
PPTX
How to dominate a free theme WCTO 2014
PDF
Steve Barman - CSS and WordPress
PPTX
HTML/CSS for WordPress
PDF
Creating Layouts and Landing Pages for Drupal 8 - DrupalCon Dublin
PPTX
Less presentation
PPT
PPT
Html & Css presentation
PPTX
WordPress Theme Development: Part 2
PPT
Spectrum 2015 going online with style - an intro to css
PDF
Be nice to your designers
PPTX
PDF
SMACSS Workshop
PDF
Modern Front-End Development
PDF
Internet Marketing Institute in Delhi
PDF
Efficient, maintainable CSS
PDF
快速开发Css
PPTX
Custom WordPress theme development
Basics of Front End Web Dev PowerPoint
Drupal distributions - how to build them
Introduction to Custom WordPress Themeing
How to dominate a free theme WCTO 2014
Steve Barman - CSS and WordPress
HTML/CSS for WordPress
Creating Layouts and Landing Pages for Drupal 8 - DrupalCon Dublin
Less presentation
Html & Css presentation
WordPress Theme Development: Part 2
Spectrum 2015 going online with style - an intro to css
Be nice to your designers
SMACSS Workshop
Modern Front-End Development
Internet Marketing Institute in Delhi
Efficient, maintainable CSS
快速开发Css
Custom WordPress theme development
Ad

Viewers also liked (15)

PDF
The Minimum Loveable Product
PDF
The Cloud Revolution
PPTX
AWIS Offers: ResponseNow Anywhere
PPTX
Lies, Damn Lies and Social Statistics
PDF
How to create a product that people love (in 12 weeks!)
PDF
LinxFIT 7 GDK UX Tips
PDF
10 common UX mistakes startups make (and how to avoid them)
PPTX
Facebook Reactions
PPTX
15 years of Shazam
PDF
The Case Behind User Experience
PDF
Bots by Ogilvy
PPTX
Point of Care Messaging
PDF
The future of mobile apps
PDF
SXSW 2016: The Need To Knows
The Minimum Loveable Product
The Cloud Revolution
AWIS Offers: ResponseNow Anywhere
Lies, Damn Lies and Social Statistics
How to create a product that people love (in 12 weeks!)
LinxFIT 7 GDK UX Tips
10 common UX mistakes startups make (and how to avoid them)
Facebook Reactions
15 years of Shazam
The Case Behind User Experience
Bots by Ogilvy
Point of Care Messaging
The future of mobile apps
SXSW 2016: The Need To Knows
Ad

Similar to Efficient theming in Drupal (20)

PPTX
Drupalcamp Atlanta 2010 Design-to-Theme
PDF
Drupaldelphia Shortcuts Cheats And Cheap Stunts
PDF
(some) Drupal Theming by Ryan Price
KEY
Grok Drupal (7) Theming (presented at DrupalCon San Francisco)
PPTX
Atlanta Drupal User Group (ADUG)
ODP
Drupal Theme Development - DrupalCon Chicago 2011
PDF
Drupalcamp performance
KEY
PSD to Drupal - Introductory Drupal Theming
PDF
New Adventures in Drupal Theming
PPTX
Theming Drupal: Beyond the Look and Feel
PPTX
Front end performance optimization
PDF
Mobile and web optimization + Drupal
PDF
Intro to Theming Drupal, FOSSLC Summer Camp 2010
PDF
Learning PHP for Drupal Theming, DC Chicago 2009
ODP
DrupalEasy: Intro to Theme Development
PDF
Building an Initial Custom Theme
PDF
Design to Theme @ CMSExpo
PDF
Nanocon Taiwan
PPTX
Drupal theme development
PDF
Drupal theming training
Drupalcamp Atlanta 2010 Design-to-Theme
Drupaldelphia Shortcuts Cheats And Cheap Stunts
(some) Drupal Theming by Ryan Price
Grok Drupal (7) Theming (presented at DrupalCon San Francisco)
Atlanta Drupal User Group (ADUG)
Drupal Theme Development - DrupalCon Chicago 2011
Drupalcamp performance
PSD to Drupal - Introductory Drupal Theming
New Adventures in Drupal Theming
Theming Drupal: Beyond the Look and Feel
Front end performance optimization
Mobile and web optimization + Drupal
Intro to Theming Drupal, FOSSLC Summer Camp 2010
Learning PHP for Drupal Theming, DC Chicago 2009
DrupalEasy: Intro to Theme Development
Building an Initial Custom Theme
Design to Theme @ CMSExpo
Nanocon Taiwan
Drupal theme development
Drupal theming training

Recently uploaded (20)

PPTX
MYSQL Presentation for SQL database connectivity
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Electronic commerce courselecture one. Pdf
PPTX
A Presentation on Artificial Intelligence
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
cuic standard and advanced reporting.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Approach and Philosophy of On baking technology
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Chapter 3 Spatial Domain Image Processing.pdf
MYSQL Presentation for SQL database connectivity
Building Integrated photovoltaic BIPV_UPV.pdf
Electronic commerce courselecture one. Pdf
A Presentation on Artificial Intelligence
gpt5_lecture_notes_comprehensive_20250812015547.pdf
cuic standard and advanced reporting.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
NewMind AI Weekly Chronicles - August'25-Week II
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Per capita expenditure prediction using model stacking based on satellite ima...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
“AI and Expert System Decision Support & Business Intelligence Systems”
Approach and Philosophy of On baking technology
Review of recent advances in non-invasive hemoglobin estimation
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Advanced methodologies resolving dimensionality complications for autism neur...
Dropbox Q2 2025 Financial Results & Investor Presentation
Chapter 3 Spatial Domain Image Processing.pdf

Efficient theming in Drupal

  • 1. Efficient theming for Drupal
  • 2. About us @CedricS • Frontend Developers Cedric Spillebeen • Focus on Dev and UX @janyves • krimson.be Jan-yves Vanhaverbeke @elswens Els Wens
  • 3. Agenda • Introduction • Optimal Design Input • From Design to Theme • Basic Frontend Performance • Questions?
  • 4. Introduction • Drupal is a CMS. • Content-first approach. • Built by backend developers. “ The Views output contains a rich set of div tags allowing fine-grained CSS control over the output. ”
  • 5. Introduction • Get optimal design input. (complete designs) • A way of working that leads to a Drupal theme that is flexible, maintainable and consistent. • Optimize the Frontend Performance.
  • 7. Problems with designs • A design is static but Drupal is flexible. • Not all pages will be designed. • Designs are rarely consistent. • A design reflects the ideal situation.
  • 8. Solutions • Take out inconsistencies before the final delivery. • Check for feasibility. • Ask for a style guide.
  • 9. Style guide • An overview of all recurring design elements. • A requirement for every CMS design. • A separate design with all elements in the site. • Leading in case of inconsistencies.
  • 10. Style guide • Site elements: • Navigations: including mouse-over and active states. • One or more block templates. • A pager. • Message boxes: warning, confirmation and error. • A form. Typically useful for the contact form. • A list of the most important colors.
  • 11. Style guide • Typography: • Headings: H1, H2, H3 and H4. • Links: color and (optional) underline. Also define a mouse-over state. • Paragraph: for default text the line-height and space between text should be defined. • Unordered list: How does an unordered list in content look?
  • 12. From design to theme
  • 14. Analyze the design • Print all designs. • Look for patterns: • Image styles • View Modes • Decide on HTML tags / classes / IDs
  • 15. Optimize the HTML • Don’t just take what Drupal offers by default. • Case: Views + Panels + Display Suite.
  • 16. Optimize the HTML • Don’t just take what Drupal offers by default. • Case: Views + Panels + Display Suite.
  • 17. Optimize the HTML • Don’t just take what Drupal offers by default. • Case: Views + Panels + Display Suite.
  • 18. Optimize the HTML • Don’t just take what Drupal offers by default. • Case: Views + Panels + Display Suite. • Use generic classes above IDs. • Replace module specific HTML.
  • 19. First step • Get the basics right first! • Add a simple page with mixed typographical content. • Style all generic elements: header, footer, navigation, typography, colors, links etc.
  • 20. Keep your CSS flexible • Work as generic as possible. .field vs .page-article #content div.node div.field-title
  • 21. Keep your CSS flexible • Theme a visual element, not a Drupal module: .article-teaser vs .views-articles .views- row
  • 22. Keep your CSS flexible • Dare to rework existing CSS as features are added.
  • 23. Optimize your CSS • Remove Drupal and module CSS (see Frontend Performance). • Use Drupal CSS standards: http://drupal.org/ node/302199 • Use comments to add structure to your CSS. /* * Navigation */ /* Sidebar Navigation */
  • 25. Reduce download size • Clean up your HTML. • Gzip compression for HTML. • mod_expires in Apache. • Optimize your images: http://drupal.org/ project/imageapi_optimize. • Use Image Styles and Image Resize Filter.
  • 26. Reduce download size • Remove unused Drupal and module CSS and javascript: • hook_css_alter() • hook_js_alter() • Add page specific CSS and javascript: • drupal_add_css() • drupal_add_js()
  • 27. Less HTTP requests • Aggregate CSS and javascript. • Combine different groups into one: /** /** * Implements hook_js_alter(). * Implements hook_css_alter(). */ */ function mymodule_js_alter(&$javascript) { function mymodule_css_alter(&$css) { uasort($javascript, 'drupal_sort_css_js'); uasort($css, 'drupal_sort_css_js'); $i = 0; $i = 0; foreach ($javascript as $name => $script) { foreach ($css as $name => $style) { $javascript[$name]['weight'] = $i++; $css[$name]['weight'] = $i++; $javascript[$name]['group'] = JS_DEFAULT; $css[$name]['group'] = CSS_DEFAULT; $javascript[$name]['every_page'] = FALSE; $css[$name]['every_page'] = FALSE; } } } }
  • 28. Other • Move JS to the bottom in your html.tpl.php. • Use a CDN: http://drupal.org/project/cdn. • Test your site with Yslow.

Editor's Notes

  • #2: \n
  • #3: \n
  • #4: \n
  • #5: Drupal is a CMS, thus flexible. \nBuilt by developers: the theming layer is super-flexible but very technical.\nContent-first approach: you have to build the site first, before you can start to theme. This is largely due to the fact that there are always several ways to achieve one goal, each with different HTML. So you can’t go from design to HTML without keeping Drupal HTML into account.\nQuote: one of the big issues in Drupal. Drupal 7 is already better, and Drupal 8 will be a lot better in this area.\n
  • #6: Let’s compare to backend development: there is Functional Analysis and Technical Analysis. But in most companies, Frontend Development is an afterthought. \n\nNot: these are great tools, but should not patch up a bad process. Get your basics right first.\n
  • #7: \n
  • #8: A design is static: but Drupal is a CMS, and thus flexible. It is difficult to visualize what will happen in case blocks are added, content grows longer etc.\nNot all pages will be designed: which is not always a bad thing. As this leads to the third point: the more designs, the more inconsistencies.\nDesigns are rarely consistent: and you cannot blame the designer, since designs go back and forth between designer and client.\nIdeal situation: teaser with right length, equal height blocks etc.\n
  • #9: Inconsistencies: Sit down with the designer, and take out the risks and inconsistencies.\nFeasibility: HAALBAARHEID: zijn er zaken die heel moeilijk of niet te bereiken zijn.\nStyle guide: see next slides. \n
  • #10: Leading: important to discuss this with the designer.\n
  • #11: \n
  • #12: \n
  • #13: NA DESIGN ANALYSE ==> GEOPTIMALISEERDE DESIGNS ==> START THEMING\n\nWAT IS THEMING?\n\nTHEMING VAAK ONDERSCHAT ==> MEER DAN KLEURTJES EN AFMETINGEN\n\nEIST DOORDACHTE AANPAK ==> CONSISTENTIE & FLEXIBILITEIT\n
  • #14: WE HADDEN VANDAAG NOG DISCUSSIE ==> 2x 1 onderdeel is consistentie\n
  • #15: Consistentie: Patronen, Afbeeldingsstijlen, weergave van content\n\nZet die consistentie om naar HTML => TAGS, CLASS & ID\n
  • #16: Remember that Drupal has a content-first approach, so the developer will fill the site with content and features. \nModule specific HTML: everything is overridable in Drupal so use that to make the HTML consistent. It will hugely improve the quality of your CSS.\n\nCase: we will compare a Default Drupal 7 with some Views and some content, and our optimized Drupal. For coolness, we will do a 3D comparison in Firefox.\n
  • #17: Remember that Drupal has a content-first approach, so the developer will fill the site with content and features. \nModule specific HTML: everything is overridable in Drupal so use that to make the HTML consistent. It will hugely improve the quality of your CSS.\n\nCase: we will compare a Default Drupal 7 with some Views and some content, and our optimized Drupal. For coolness, we will do a 3D comparison in Firefox.\n
  • #18: Remember that Drupal has a content-first approach, so the developer will fill the site with content and features. \nModule specific HTML: everything is overridable in Drupal so use that to make the HTML consistent. It will hugely improve the quality of your CSS.\n\nCase: we will compare a Default Drupal 7 with some Views and some content, and our optimized Drupal. For coolness, we will do a 3D comparison in Firefox.\n
  • #19: Remember that Drupal has a content-first approach, so the developer will fill the site with content and features. \nModule specific HTML: everything is overridable in Drupal so use that to make the HTML consistent. It will hugely improve the quality of your CSS.\n\nCase: we will compare a Default Drupal 7 with some Views and some content, and our optimized Drupal. For coolness, we will do a 3D comparison in Firefox.\n
  • #20: Start met de basis!\n
  • #21: Generic: it’s not about being sure it won’t break. It is about reusability and consistency.\n\nVisual element = an article teaser. Every module has its own output, such as Panels or Views, but don’t theme on it.\n
  • #22: Generic: it’s not about being sure it won’t break. It is about reusability and consistency.\n\nVisual element = an article teaser. Every module has its own output, such as Panels or Views, but don’t theme on it.\n
  • #23: Generic: it’s not about being sure it won’t break. It is about reusability and consistency.\n\nVisual element = an article teaser. Every module has its own output, such as Panels or Views, but don’t theme on it.\n
  • #24: \n
  • #25: We will only focus on the Drupal specifics here, not Frontend Performance in general.\n\nImportant for mobile devices. 20% server time and 80% client side.\n
  • #26: Gzip compression is available in Drupal, but you should do it on server level.\nmod_expires: Drupal adds cache expiration headers by default but you need to activate this Apache module.\nImage Styles: Image size presets.\nImage Resize Filter: solves the issue of huge images that are manually rescaled in the WYSIWYG.\n
  • #27: Every module adds its own CSS and possibly JS. Always check if you even use those files. \nOr if you feel like you are overwriting everything, think twice.\n\nDon’t stuff everything in your .info file.\n
  • #28: Aggregate: Configuration > Performance\nFewer HTTP requests are better than smaller files.\nCombine: SYSTEM, DEFAULT, THEME\n\nOther options such as sprites are also useful, but we want to focus on Drupal specific options.\n
  • #29: \n
  • #30: \n