SlideShare a Scribd company logo
1 of 28
Front End Architecture
Performance Focused Theming
Jason Stanbery
Front End Architect
Performance Topics
→Base Theme Selection
→Content Images
→Theme Images
→Styles
→JavaScript
→HTML
Theming for Performance
→ This is a guide
→ This isn’t 100% accurate in
100% of the cases
→ This can’t and won’t cover
everything
→ I’m not a performance “expert”
→ Some Science
→ Some Voodoo
→ Some WTF
Goals
→Minimize payload
→Minimize http requests
→Minimize render blocking assets
Base Theme Considerations
→Is it a completely custom design?
→What tools are out of the box?
→Is this a consistent starting point for all projects?
Base Theme Selection
→Choose a blank canvas themes
 Light weight themes
• Don’t require you to overwrite everything.
• Don’t load unused styles and scripts.
• Don’t make assumptions about your design and
functionality.
Base Theme Impact on Performance
→Payload size
→JavaScript Library Dependencies
→CDN Delivered Assets
Images
→Theme images
 Tracked in version control
 Live in your theme directory
→Content images
 Referenced in the database
 Live in your files directory
Theme Images
→Greater amount of control
→Sprite all the things
→Optimize all the things
Sprites
→Combine images into one
image
→File size is often less then
the sum of individual files
→One http request
→A lot of tools for sprite
generation
Better then Sprites?
→Font Icons
 Smaller in size
 Can be sized up
without getting
pixelated
 Easy to change color
Content Images
→Challenges
 Limited control of image selection
 Limited control of number of images
 Design and comps often dictates complex pages
Mitigate Content Image Risks
→Serve an image appropriate for the device
 Picture module, picture module, picture module
• Works with image fields
• Works with wysiwyg images (via text filter & dev
version of picture module)
• Works with views images
• Uses Image Styles to resize images per breakpoint
Styles
→Mobile First
→Aggregate the CSS
→Compress the CSS
→Reuse Styles
Why Mobile First?
<div id="test">
<h3>Demo Block</h3>
<p>Sample content.</p>
</div>
#test {
background: none;
height: 250px;
width: 250px;
padding: 10px;
}
h3 {
color: #aaa;
}
p {
color: #bbb;
}
@media (min-width: 600px) {
#test {
background: url(screenshot.png);
}
}
Write better styles
→Beware of Sass inception
(overly nesting your
selectors)
→DRY styles
→Know how to use your
tools properly
Reduce http requests for styles
→Use the theme’s .info file
→Use a preprocessor
 Or don’t
→Every page is cool
JavaScript
→Similar to CSS, but different
 Scripts not required for rendering can be in the footer
 External scripts should be not aggregated
 Scripts used on most pages should be on all pages
 Scripts on few pages but frequently visited pages
should be on all pages
JavaScript Organization
→Similar to CSS, but different
 Styles is organized by component, so should
JavaScript
• Logically break up JS in the same way you would
styles
• Don’t just have a script.js file
JavaScript Organization
drupal_add_js
→theme_preprocess_html function
 Easiest way to add scripts to the footer that you’d
normally add to the .info file
 Even though it runs on every page, make sure it’s in
your option array
→Used in custom modules to add JS to pages when
module runs
drupal_add_js
→Add external JS files
→Add JS inline
→Prevent caching of JS files
→Set JS to defer
HTML
→Control mark-up
 Tpl files
 Fences module
 Views field wrapper
→Reusable styles
 Preprocess to add
classes
 Field Formatter Class
module
 Field Formatter CSS
Class module
Bonus Points
→ Advanced Aggregation Module
 Tons of Advanced Features
→ Magic Module
 Less Features, but possibly all you need
→ CDN
 Cut down the roundtrip request time by serving static
assets from a CDN
• CloudFlare Free!!!
→ Lazy Load images outside of the viewport
Questions?
Tweet me @jasonstanbery
Thank You

More Related Content

What's hot

Object oriented css graeme blackwood
Object oriented css graeme blackwoodObject oriented css graeme blackwood
Object oriented css graeme blackwood
drupalconf
 
The Coding Designer's Survival Kit - Capital Camp
The Coding Designer's Survival Kit - Capital CampThe Coding Designer's Survival Kit - Capital Camp
The Coding Designer's Survival Kit - Capital Camp
canarymason
 
Designing in the Browser - Mason Wendell, Drupaldelphia
Designing in the Browser - Mason Wendell, DrupaldelphiaDesigning in the Browser - Mason Wendell, Drupaldelphia
Designing in the Browser - Mason Wendell, Drupaldelphia
canarymason
 
Sass: The Future of Stylesheets
Sass: The Future of StylesheetsSass: The Future of Stylesheets
Sass: The Future of Stylesheets
chriseppstein
 
Convert a Site Template to a Drupal 7 Theme using SASS or LESS and Zurb Found...
Convert a Site Template to a Drupal 7 Theme using SASS or LESS and Zurb Found...Convert a Site Template to a Drupal 7 Theme using SASS or LESS and Zurb Found...
Convert a Site Template to a Drupal 7 Theme using SASS or LESS and Zurb Found...
Carlos Ospina
 

What's hot (20)

SASS for WordPress Workshop
SASS for WordPress WorkshopSASS for WordPress Workshop
SASS for WordPress Workshop
 
Object oriented css graeme blackwood
Object oriented css graeme blackwoodObject oriented css graeme blackwood
Object oriented css graeme blackwood
 
The way to be a developer "What I Need"
The way to be a developer "What I Need"The way to be a developer "What I Need"
The way to be a developer "What I Need"
 
The Coding Designer's Survival Kit - Capital Camp
The Coding Designer's Survival Kit - Capital CampThe Coding Designer's Survival Kit - Capital Camp
The Coding Designer's Survival Kit - Capital Camp
 
Designing in the Browser - Mason Wendell, Drupaldelphia
Designing in the Browser - Mason Wendell, DrupaldelphiaDesigning in the Browser - Mason Wendell, Drupaldelphia
Designing in the Browser - Mason Wendell, Drupaldelphia
 
Sass: The Future of Stylesheets
Sass: The Future of StylesheetsSass: The Future of Stylesheets
Sass: The Future of Stylesheets
 
Novajs
NovajsNovajs
Novajs
 
WordPress Themes - From Designer’s Perspective
WordPress Themes - From Designer’s PerspectiveWordPress Themes - From Designer’s Perspective
WordPress Themes - From Designer’s Perspective
 
Variations on a Theme
Variations on a ThemeVariations on a Theme
Variations on a Theme
 
Tools for Modern Web Design
Tools for Modern Web DesignTools for Modern Web Design
Tools for Modern Web Design
 
HTML5shim
HTML5shimHTML5shim
HTML5shim
 
Mobile and Responsive Design with Sass
Mobile and Responsive Design with SassMobile and Responsive Design with Sass
Mobile and Responsive Design with Sass
 
Convert a Site Template to a Drupal 7 Theme using SASS or LESS and Zurb Found...
Convert a Site Template to a Drupal 7 Theme using SASS or LESS and Zurb Found...Convert a Site Template to a Drupal 7 Theme using SASS or LESS and Zurb Found...
Convert a Site Template to a Drupal 7 Theme using SASS or LESS and Zurb Found...
 
JavaScript : A trending scripting language
JavaScript : A trending scripting languageJavaScript : A trending scripting language
JavaScript : A trending scripting language
 
Intro to Sails.js
Intro to Sails.jsIntro to Sails.js
Intro to Sails.js
 
Front End Development - Beyond Javascript (Robin Cannon)
Front End Development - Beyond Javascript (Robin Cannon)Front End Development - Beyond Javascript (Robin Cannon)
Front End Development - Beyond Javascript (Robin Cannon)
 
Introduction to the wonderful world of JavaScript
Introduction to the wonderful world of JavaScriptIntroduction to the wonderful world of JavaScript
Introduction to the wonderful world of JavaScript
 
CSS Grid
CSS GridCSS Grid
CSS Grid
 
It's a Mod World - A Practical Guide to Rocking Modernizr
It's a Mod World - A Practical Guide to Rocking ModernizrIt's a Mod World - A Practical Guide to Rocking Modernizr
It's a Mod World - A Practical Guide to Rocking Modernizr
 
ATO- Intro to Web Concepts
ATO- Intro to Web ConceptsATO- Intro to Web Concepts
ATO- Intro to Web Concepts
 

Similar to Make Your Site Faster: How to Improve Front-End Performance Strategy

Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Erin M. Kidwell
 
Forensic Theming - DrupalCon London
Forensic Theming - DrupalCon LondonForensic Theming - DrupalCon London
Forensic Theming - DrupalCon London
Emma Jane Hogbin Westby
 
CSS Methodology
CSS MethodologyCSS Methodology
CSS Methodology
Zohar Arad
 
Atlanta Drupal User Group (ADUG)
Atlanta Drupal User Group (ADUG) Atlanta Drupal User Group (ADUG)
Atlanta Drupal User Group (ADUG)
Mediacurrent
 
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
Deepak Sharma
 

Similar to Make Your Site Faster: How to Improve Front-End Performance Strategy (20)

Efficient theming in Drupal
Efficient theming in DrupalEfficient theming in Drupal
Efficient theming in Drupal
 
Css
CssCss
Css
 
An Introduction to CSS Frameworks
An Introduction to CSS FrameworksAn Introduction to CSS Frameworks
An Introduction to CSS Frameworks
 
Front-End Frameworks: a quick overview
Front-End Frameworks: a quick overviewFront-End Frameworks: a quick overview
Front-End Frameworks: a quick overview
 
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
 
Responsive Web Design: Clever Tips and Techniques
Responsive Web Design: Clever Tips and TechniquesResponsive Web Design: Clever Tips and Techniques
Responsive Web Design: Clever Tips and Techniques
 
Does my DIV look big in this?
Does my DIV look big in this?Does my DIV look big in this?
Does my DIV look big in this?
 
Forensic Theming - DrupalCon London
Forensic Theming - DrupalCon LondonForensic Theming - DrupalCon London
Forensic Theming - DrupalCon London
 
HTML CSS & Javascript
HTML CSS & JavascriptHTML CSS & Javascript
HTML CSS & Javascript
 
From PSD to WordPress Theme: Bringing designs to life
From PSD to WordPress Theme: Bringing designs to lifeFrom PSD to WordPress Theme: Bringing designs to life
From PSD to WordPress Theme: Bringing designs to life
 
Advanced sass/compass
Advanced sass/compassAdvanced sass/compass
Advanced sass/compass
 
CSS Methodology
CSS MethodologyCSS Methodology
CSS Methodology
 
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
 
Teams, styles and scalable applications
Teams, styles and scalable applicationsTeams, styles and scalable applications
Teams, styles and scalable applications
 
Responsive content
Responsive contentResponsive content
Responsive content
 
Rapid and Responsive - UX to Prototype with Bootstrap
Rapid and Responsive - UX to Prototype with BootstrapRapid and Responsive - UX to Prototype with Bootstrap
Rapid and Responsive - UX to Prototype with Bootstrap
 
Atlanta Drupal User Group (ADUG)
Atlanta Drupal User Group (ADUG) Atlanta Drupal User Group (ADUG)
Atlanta Drupal User Group (ADUG)
 
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
 
Css best practices style guide and tips
Css best practices style guide and tipsCss best practices style guide and tips
Css best practices style guide and tips
 
Please dont touch-3.6-jsday
Please dont touch-3.6-jsdayPlease dont touch-3.6-jsday
Please dont touch-3.6-jsday
 

More from Acquia

Taking Your Multi-Site Management at Scale to the Next Level
Taking Your Multi-Site Management at Scale to the Next LevelTaking Your Multi-Site Management at Scale to the Next Level
Taking Your Multi-Site Management at Scale to the Next Level
Acquia
 

More from Acquia (20)

Acquia_Adcetera Webinar_Marketing Automation.pdf
Acquia_Adcetera Webinar_Marketing Automation.pdfAcquia_Adcetera Webinar_Marketing Automation.pdf
Acquia_Adcetera Webinar_Marketing Automation.pdf
 
Acquia Webinar Deck - 9_13 .pdf
Acquia Webinar Deck - 9_13 .pdfAcquia Webinar Deck - 9_13 .pdf
Acquia Webinar Deck - 9_13 .pdf
 
Taking Your Multi-Site Management at Scale to the Next Level
Taking Your Multi-Site Management at Scale to the Next LevelTaking Your Multi-Site Management at Scale to the Next Level
Taking Your Multi-Site Management at Scale to the Next Level
 
CDP for Retail Webinar with Appnovation - Q2 2022.pdf
CDP for Retail Webinar with Appnovation - Q2 2022.pdfCDP for Retail Webinar with Appnovation - Q2 2022.pdf
CDP for Retail Webinar with Appnovation - Q2 2022.pdf
 
May Partner Bootcamp 2022
May Partner Bootcamp 2022May Partner Bootcamp 2022
May Partner Bootcamp 2022
 
April Partner Bootcamp 2022
April Partner Bootcamp 2022April Partner Bootcamp 2022
April Partner Bootcamp 2022
 
How to Unify Brand Experience: A Hootsuite Story
How to Unify Brand Experience: A Hootsuite Story How to Unify Brand Experience: A Hootsuite Story
How to Unify Brand Experience: A Hootsuite Story
 
Using Personas to Guide DAM Results: How Life Time Pumped Up Their UX and CX
Using Personas to Guide DAM Results: How Life Time Pumped Up Their UX and CXUsing Personas to Guide DAM Results: How Life Time Pumped Up Their UX and CX
Using Personas to Guide DAM Results: How Life Time Pumped Up Their UX and CX
 
Improve Code Quality and Time to Market: 100% Cloud-Based Development Workflow
Improve Code Quality and Time to Market: 100% Cloud-Based Development WorkflowImprove Code Quality and Time to Market: 100% Cloud-Based Development Workflow
Improve Code Quality and Time to Market: 100% Cloud-Based Development Workflow
 
September Partner Bootcamp
September Partner BootcampSeptember Partner Bootcamp
September Partner Bootcamp
 
August partner bootcamp
August partner bootcampAugust partner bootcamp
August partner bootcamp
 
July 2021 Partner Bootcamp
July  2021 Partner BootcampJuly  2021 Partner Bootcamp
July 2021 Partner Bootcamp
 
May Partner Bootcamp
May Partner BootcampMay Partner Bootcamp
May Partner Bootcamp
 
DRUPAL 7 END OF LIFE IS NEAR - MIGRATE TO DRUPAL 9 FAST AND EASY
DRUPAL 7 END OF LIFE IS NEAR - MIGRATE TO DRUPAL 9 FAST AND EASYDRUPAL 7 END OF LIFE IS NEAR - MIGRATE TO DRUPAL 9 FAST AND EASY
DRUPAL 7 END OF LIFE IS NEAR - MIGRATE TO DRUPAL 9 FAST AND EASY
 
Work While You Sleep: The CMO’s Guide to a 24/7/365 Lead Machine
Work While You Sleep: The CMO’s Guide to a 24/7/365 Lead MachineWork While You Sleep: The CMO’s Guide to a 24/7/365 Lead Machine
Work While You Sleep: The CMO’s Guide to a 24/7/365 Lead Machine
 
Acquia webinar: Leveraging Drupal to Bury Your Sales Team In B2B Leads
Acquia webinar: Leveraging Drupal to Bury Your Sales Team In B2B LeadsAcquia webinar: Leveraging Drupal to Bury Your Sales Team In B2B Leads
Acquia webinar: Leveraging Drupal to Bury Your Sales Team In B2B Leads
 
April partner bootcamp deck cookieless future
April partner bootcamp deck  cookieless futureApril partner bootcamp deck  cookieless future
April partner bootcamp deck cookieless future
 
How to enhance cx through personalised, automated solutions
How to enhance cx through personalised, automated solutionsHow to enhance cx through personalised, automated solutions
How to enhance cx through personalised, automated solutions
 
DRUPAL MIGRATIONS AND DRUPAL 9 INNOVATION: HOW PAC-12 DELIVERED DIGITALLY FOR...
DRUPAL MIGRATIONS AND DRUPAL 9 INNOVATION: HOW PAC-12 DELIVERED DIGITALLY FOR...DRUPAL MIGRATIONS AND DRUPAL 9 INNOVATION: HOW PAC-12 DELIVERED DIGITALLY FOR...
DRUPAL MIGRATIONS AND DRUPAL 9 INNOVATION: HOW PAC-12 DELIVERED DIGITALLY FOR...
 
Customer Experience (CX): 3 Key Factors Shaping CX Redesign in 2021
Customer Experience (CX): 3 Key Factors Shaping CX Redesign in 2021Customer Experience (CX): 3 Key Factors Shaping CX Redesign in 2021
Customer Experience (CX): 3 Key Factors Shaping CX Redesign in 2021
 

Recently uploaded

Recently uploaded (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
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
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 

Make Your Site Faster: How to Improve Front-End Performance Strategy

  • 1. Front End Architecture Performance Focused Theming Jason Stanbery Front End Architect
  • 2. Performance Topics →Base Theme Selection →Content Images →Theme Images →Styles →JavaScript →HTML
  • 3. Theming for Performance → This is a guide → This isn’t 100% accurate in 100% of the cases → This can’t and won’t cover everything → I’m not a performance “expert” → Some Science → Some Voodoo → Some WTF
  • 4. Goals →Minimize payload →Minimize http requests →Minimize render blocking assets
  • 5. Base Theme Considerations →Is it a completely custom design? →What tools are out of the box? →Is this a consistent starting point for all projects?
  • 6. Base Theme Selection →Choose a blank canvas themes  Light weight themes • Don’t require you to overwrite everything. • Don’t load unused styles and scripts. • Don’t make assumptions about your design and functionality.
  • 7. Base Theme Impact on Performance →Payload size →JavaScript Library Dependencies →CDN Delivered Assets
  • 8. Images →Theme images  Tracked in version control  Live in your theme directory →Content images  Referenced in the database  Live in your files directory
  • 9. Theme Images →Greater amount of control →Sprite all the things →Optimize all the things
  • 10. Sprites →Combine images into one image →File size is often less then the sum of individual files →One http request →A lot of tools for sprite generation
  • 11. Better then Sprites? →Font Icons  Smaller in size  Can be sized up without getting pixelated  Easy to change color
  • 12. Content Images →Challenges  Limited control of image selection  Limited control of number of images  Design and comps often dictates complex pages
  • 13. Mitigate Content Image Risks →Serve an image appropriate for the device  Picture module, picture module, picture module • Works with image fields • Works with wysiwyg images (via text filter & dev version of picture module) • Works with views images • Uses Image Styles to resize images per breakpoint
  • 14. Styles →Mobile First →Aggregate the CSS →Compress the CSS →Reuse Styles
  • 15. Why Mobile First? <div id="test"> <h3>Demo Block</h3> <p>Sample content.</p> </div> #test { background: none; height: 250px; width: 250px; padding: 10px; } h3 { color: #aaa; } p { color: #bbb; } @media (min-width: 600px) { #test { background: url(screenshot.png); } }
  • 16.
  • 17. Write better styles →Beware of Sass inception (overly nesting your selectors) →DRY styles →Know how to use your tools properly
  • 18. Reduce http requests for styles →Use the theme’s .info file →Use a preprocessor  Or don’t →Every page is cool
  • 19. JavaScript →Similar to CSS, but different  Scripts not required for rendering can be in the footer  External scripts should be not aggregated  Scripts used on most pages should be on all pages  Scripts on few pages but frequently visited pages should be on all pages
  • 20. JavaScript Organization →Similar to CSS, but different  Styles is organized by component, so should JavaScript • Logically break up JS in the same way you would styles • Don’t just have a script.js file
  • 22. drupal_add_js →theme_preprocess_html function  Easiest way to add scripts to the footer that you’d normally add to the .info file  Even though it runs on every page, make sure it’s in your option array →Used in custom modules to add JS to pages when module runs
  • 23.
  • 24. drupal_add_js →Add external JS files →Add JS inline →Prevent caching of JS files →Set JS to defer
  • 25. HTML →Control mark-up  Tpl files  Fences module  Views field wrapper →Reusable styles  Preprocess to add classes  Field Formatter Class module  Field Formatter CSS Class module
  • 26. Bonus Points → Advanced Aggregation Module  Tons of Advanced Features → Magic Module  Less Features, but possibly all you need → CDN  Cut down the roundtrip request time by serving static assets from a CDN • CloudFlare Free!!! → Lazy Load images outside of the viewport