SlideShare a Scribd company logo
High Performance
Images in WordPress
WordCamp London
April 2016
by Keith Devon
About me
Keith Devon
‣ Born in Canada, raised in Northern Ireland, living in
Kent, UK
‣ WordPress developer for 6 years
‣ Co-founder of Highrise Digital
@keithdevon
https://highrise.digital
The problem
The problem with images
▸ Too many
▸ Too big
▸ Device pixel ratios (DPR)
The problem
Average web page content weight distribution
3%
3%
5%
8%
16%
64%
Images Scripts
Video Fonts
Stylesheets HTML
Other
http://httparchive.org/interesting.php#bytesperpage
The solution
How can we fix our image problem?
▸ Image sprites
▸ Icon fonts
▸ Choosing the right format (.gif, .png, .jpg, SVG, etc.)
▸ Image optimisation (size and compression)
▸ Lazy loading
▸ Responsive images
The solution
How can we fix our image problem?
▸ Image sprites
▸ Icon fonts
▸ Choosing the right format (.gif, .png, .jpg, etc.)
▸ Image optimisation (size and compression)
▸ Lazy loading
▸ Responsive images
Image optimisation
Image optimisation
▸ Reduce file size of image
▸ Lossy - eliminates some pixel data
▸ Lossless - compresses pixel data
▸ No single best configuration - depends on image
▸ Online tools available
Original iPhone image

4032 x 3024

2.1 MB
Lossless compression

4032 x 3024 

1.89 MB (-6.06%)
Lossy compression + resize

1200 x 900 

226.19 KB (-89.05%)
Lossy compression

4032 x 3024 

1.71 MB (-15.13%)
Image optimisation
Kraken.io
▸ Free and paid versions
▸ Lossy or lossless options
▸ WP plugin available
Lazy loading
Lazy loading
▸ Loads images as they come into view
▸ Saves on initial page weight and HTTP requests
▸ Relies on JavaScript
▸ Lots of JS plugins available
▸ WP plugins available
High Performance Images in WordPress
Responsive images
What are responsive images?
▸ RICG
▸ <picture>
▸ srcset=“”sizes=“”
Responsive images
What are responsive images?
▸ RICG
▸ <picture>
▸ srcset=“”sizes=“”
Responsive images
srcset and sizes
▸ Used to save bandwidth
▸ Appropriate image size depending on context
▸ Browser has final control
Responsive images
srcset
<img src="small.jpg"
srcset="large.jpg 1024w, medium.jpg 640w, small.jpg 320w"
alt="A tasty potato">
Example 1
Viewport width = 320px

Pixel density = 1

Chosen image* = small.jpg
Example 2
Viewport width = 320px

Pixel density = 2

Chosen image* = medium.jpg
* Probably! (the browser decides)
Responsive images
sizes
‣ Tells browser the width that the image will be
displayed
Responsive images
sizes
<img src="small.jpg"
srcset="large.jpg 1024w, medium.jpg 640w, small.jpg 320w"
sizes="33.3vw"
alt="A tasty potato">
Responsive images
sizes
<img src="small.jpg"
srcset="large.jpg 1024w, medium.jpg 640w, small.jpg 320w"
sizes="33.3vw"
alt="A tasty potato">
High Performance Images in WordPress
Responsive images
sizes
<img src="small.jpg"
srcset="large.jpg 1024w, medium.jpg 640w, small.jpg 320w"
sizes=“(min-width: 640px) 33.3vw,
100vw”
alt="A tasty potato">
Caniuse screenshot
http://caniuse.com/#search=srcset (02/04/16)
Responsive images
Responsive images in WordPress
▸ Started with the plugin from RICG
▸ Added to core in 4.4
▸ Adds srcset and sizes support to content images
▸ New functions
▸ New default image size (‘medium_large’) 768px w
▸ No <picture> support
Responsive images
Using responsive images in your theme
$img = get_field(‘image’); // get image from ACF field
$img_id = $img['ID'];

$img_src = $img['sizes']['archive'];

$img_meta = wp_get_attachment_metadata($img_id);
$image_html = '<img src="'.$img_src.'" alt="'.$img['alt'].'" />’;
echo wp_image_add_srcset_and_sizes ( $image_html,
$img_meta, $img_id );
Responsive images
Using responsive images in your theme
Result
<img src="http://potato-passion.com/media/potato-on-table-282x212.jpg" alt=""
srcset=“http://potato-passion.com/media/potato-on-table-300x225.jpg 300w,
http://potato-passion.com/media/potato-on-table-768x576.jpg 768w,
http://potato-passion.com/media/potato-on-table-1600x1200.jpg 1600w,
http://potato-passion.com/media/potato-on-table-770x578.jpg 770w,
http://potato-passion.com/media/potato-on-table-282x212.jpg 282w,
sizes="(max-width: 282px) 100vw, 282px">
Responsive images
Using responsive images in your theme
Other thoughts
▸ Customise the ‘sizes’ output using
wp_calculate_image_sizes() filter
▸ Default is better than nothing
Responsive images
wp-lazysizes
▸ The daddy of image plugins
▸ Lazy loading AND responsive images
▸ Works out ‘sizes’ attribute for you
▸ https://github.com/aFarkas/wp-lazysizes
▸ Caveat: I haven’t used this in production yet!
Summary
What did we learn?
▸ We have an image problem
▸ We have the tools to solve it!
▸ Optimise your images
▸ Lazy-load your images
▸ Use responsive images
THANKS!
@keithdevon

More Related Content

PDF
Weniger aus Bilder holen
PDF
Word press gets responsive 4x3
ODP
Administer WordPress with WP-CLI
PDF
Dealing with media
PDF
Responsive images, an html 5.1 standard
PDF
2022.04 - CSS Day IT - Images Optimisation 4.0
PPTX
Minimize website page loading time – 20+ advanced SEO tips
PDF
A little journey into website optimization
Weniger aus Bilder holen
Word press gets responsive 4x3
Administer WordPress with WP-CLI
Dealing with media
Responsive images, an html 5.1 standard
2022.04 - CSS Day IT - Images Optimisation 4.0
Minimize website page loading time – 20+ advanced SEO tips
A little journey into website optimization

What's hot (20)

PDF
SEMCON 2013 - WordPress Optimization
PDF
How to Speed Up Your Joomla Website
PPTX
Harder, Better, Faster, Stronger
PPTX
SEO best practices to increase your page speed
PPTX
How webpage loading takes place?
PPTX
The Need for Speed - SMX Sydney 2013
PPTX
Web Optimisation
DOC
hostgator coupon code june 2014 - 50% OFF
PPTX
Website Optimization - WordPress
PPTX
How to turn your website speed from zero to hero
PPT
WebHosting Performance / WordPress - Pubcon Vegas - Hendison
PDF
Template tuning for high performance
PDF
21 Ways to Make WordPress Fast
ODP
Making Web Sites Fast - Greg Keith
PDF
Keep the Web Fast
PPTX
Using gzip to speed up performance
PDF
Guardians of the WebSite - Awesome Toolkit Vol 1
PPT
Fast Sites and SEO - PubCon 2017
PDF
Hello, Canvas.
SEMCON 2013 - WordPress Optimization
How to Speed Up Your Joomla Website
Harder, Better, Faster, Stronger
SEO best practices to increase your page speed
How webpage loading takes place?
The Need for Speed - SMX Sydney 2013
Web Optimisation
hostgator coupon code june 2014 - 50% OFF
Website Optimization - WordPress
How to turn your website speed from zero to hero
WebHosting Performance / WordPress - Pubcon Vegas - Hendison
Template tuning for high performance
21 Ways to Make WordPress Fast
Making Web Sites Fast - Greg Keith
Keep the Web Fast
Using gzip to speed up performance
Guardians of the WebSite - Awesome Toolkit Vol 1
Fast Sites and SEO - PubCon 2017
Hello, Canvas.
Ad

Viewers also liked (18)

PDF
Shiny Updates, A Feature Plugin in Two Acts
PDF
How to make your WordPress website Multilingual - WordCamp London 2016
PDF
7 Tips on Getting Your Theme Approved the First Time
PDF
The How & Why Of Small Business Blogging
PDF
Tiny homes4thehomeless (1)
PDF
Health for all
PDF
Coder keyspres
PPTX
Discount driver
PDF
The great traffic stop de escalator
PDF
Gov gush chasemoore_rivertonhs-ut_v1.2
PDF
PDF
Colo clean hsuec (1)
PDF
Bird scare device air dancer
PPTX
Deflame presentation
PDF
Headshot (1)
PDF
VersionPress - WordPress + Git
PPTX
Not One and Done - Repurposing Your Content
Shiny Updates, A Feature Plugin in Two Acts
How to make your WordPress website Multilingual - WordCamp London 2016
7 Tips on Getting Your Theme Approved the First Time
The How & Why Of Small Business Blogging
Tiny homes4thehomeless (1)
Health for all
Coder keyspres
Discount driver
The great traffic stop de escalator
Gov gush chasemoore_rivertonhs-ut_v1.2
Colo clean hsuec (1)
Bird scare device air dancer
Deflame presentation
Headshot (1)
VersionPress - WordPress + Git
Not One and Done - Repurposing Your Content
Ad

Similar to High Performance Images in WordPress (20)

PDF
Responsive Web Design: Clever Tips and Techniques
PDF
Rwd slidedeck
PDF
Responsive Web Design tips and tricks.
PPTX
Responsive images
PDF
High Performance Images: Beautiful Shouldn't Mean Slow
PDF
Delivering Responsive Images
PDF
The Need for Speed (5 Performance Optimization Tipps) - brightonSEO 2014
PPTX
Mo’ Pixels Mo’ Problems: Moving Toward a Resolution Independent Web
PDF
Better DITA Graphics for a Multi-Screen World
PPTX
A holistic approach to web performance
PDF
Delivering Optimal Images for Phones and Tablets on the Modern Web
PDF
Responsive Images - SMX Milan 2015
PDF
An Introduction to Responsive Design
PPTX
SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design
PDF
"Responsive Web Design: Clever Tips and Techniques". Vitaly Friedman, Smashin...
PDF
[CSSDevConf] Adaptive Images in Responsive Web Design 2014
PDF
[cssdevconf] Adaptive Images in RWD
PDF
Responsive & Responsible: Implementing Responsive Design at Scale
PDF
[html5tx] Adaptive Images in Responsive Web Design
PDF
[rwdsummit2012] Adaptive Images in Responsive Web Design
Responsive Web Design: Clever Tips and Techniques
Rwd slidedeck
Responsive Web Design tips and tricks.
Responsive images
High Performance Images: Beautiful Shouldn't Mean Slow
Delivering Responsive Images
The Need for Speed (5 Performance Optimization Tipps) - brightonSEO 2014
Mo’ Pixels Mo’ Problems: Moving Toward a Resolution Independent Web
Better DITA Graphics for a Multi-Screen World
A holistic approach to web performance
Delivering Optimal Images for Phones and Tablets on the Modern Web
Responsive Images - SMX Milan 2015
An Introduction to Responsive Design
SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design
"Responsive Web Design: Clever Tips and Techniques". Vitaly Friedman, Smashin...
[CSSDevConf] Adaptive Images in Responsive Web Design 2014
[cssdevconf] Adaptive Images in RWD
Responsive & Responsible: Implementing Responsive Design at Scale
[html5tx] Adaptive Images in Responsive Web Design
[rwdsummit2012] Adaptive Images in Responsive Web Design

Recently uploaded (20)

PPTX
international classification of diseases ICD-10 review PPT.pptx
PDF
Smart Home Technology for Health Monitoring (www.kiu.ac.ug)
PDF
Cloud-Scale Log Monitoring _ Datadog.pdf
PPTX
innovation process that make everything different.pptx
PPT
Design_with_Watersergyerge45hrbgre4top (1).ppt
PDF
Introduction to the IoT system, how the IoT system works
PPTX
introduction about ICD -10 & ICD-11 ppt.pptx
PPTX
Funds Management Learning Material for Beg
PPTX
522797556-Unit-2-Temperature-measurement-1-1.pptx
PPT
isotopes_sddsadsaadasdasdasdasdsa1213.ppt
DOCX
Unit-3 cyber security network security of internet system
PPTX
presentation_pfe-universite-molay-seltan.pptx
PPTX
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
PDF
Exploring VPS Hosting Trends for SMBs in 2025
PDF
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
PDF
Paper PDF World Game (s) Great Redesign.pdf
PPTX
INTERNET------BASICS-------UPDATED PPT PRESENTATION
PDF
SASE Traffic Flow - ZTNA Connector-1.pdf
PPTX
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
PPTX
Internet___Basics___Styled_ presentation
international classification of diseases ICD-10 review PPT.pptx
Smart Home Technology for Health Monitoring (www.kiu.ac.ug)
Cloud-Scale Log Monitoring _ Datadog.pdf
innovation process that make everything different.pptx
Design_with_Watersergyerge45hrbgre4top (1).ppt
Introduction to the IoT system, how the IoT system works
introduction about ICD -10 & ICD-11 ppt.pptx
Funds Management Learning Material for Beg
522797556-Unit-2-Temperature-measurement-1-1.pptx
isotopes_sddsadsaadasdasdasdasdsa1213.ppt
Unit-3 cyber security network security of internet system
presentation_pfe-universite-molay-seltan.pptx
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
Exploring VPS Hosting Trends for SMBs in 2025
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
Paper PDF World Game (s) Great Redesign.pdf
INTERNET------BASICS-------UPDATED PPT PRESENTATION
SASE Traffic Flow - ZTNA Connector-1.pdf
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
Internet___Basics___Styled_ presentation

High Performance Images in WordPress

  • 1. High Performance Images in WordPress WordCamp London April 2016 by Keith Devon
  • 2. About me Keith Devon ‣ Born in Canada, raised in Northern Ireland, living in Kent, UK ‣ WordPress developer for 6 years ‣ Co-founder of Highrise Digital @keithdevon https://highrise.digital
  • 3. The problem The problem with images ▸ Too many ▸ Too big ▸ Device pixel ratios (DPR)
  • 4. The problem Average web page content weight distribution 3% 3% 5% 8% 16% 64% Images Scripts Video Fonts Stylesheets HTML Other http://httparchive.org/interesting.php#bytesperpage
  • 5. The solution How can we fix our image problem? ▸ Image sprites ▸ Icon fonts ▸ Choosing the right format (.gif, .png, .jpg, SVG, etc.) ▸ Image optimisation (size and compression) ▸ Lazy loading ▸ Responsive images
  • 6. The solution How can we fix our image problem? ▸ Image sprites ▸ Icon fonts ▸ Choosing the right format (.gif, .png, .jpg, etc.) ▸ Image optimisation (size and compression) ▸ Lazy loading ▸ Responsive images
  • 7. Image optimisation Image optimisation ▸ Reduce file size of image ▸ Lossy - eliminates some pixel data ▸ Lossless - compresses pixel data ▸ No single best configuration - depends on image ▸ Online tools available
  • 8. Original iPhone image
 4032 x 3024
 2.1 MB Lossless compression
 4032 x 3024 
 1.89 MB (-6.06%) Lossy compression + resize
 1200 x 900 
 226.19 KB (-89.05%) Lossy compression
 4032 x 3024 
 1.71 MB (-15.13%)
  • 9. Image optimisation Kraken.io ▸ Free and paid versions ▸ Lossy or lossless options ▸ WP plugin available
  • 10. Lazy loading Lazy loading ▸ Loads images as they come into view ▸ Saves on initial page weight and HTTP requests ▸ Relies on JavaScript ▸ Lots of JS plugins available ▸ WP plugins available
  • 12. Responsive images What are responsive images? ▸ RICG ▸ <picture> ▸ srcset=“”sizes=“”
  • 13. Responsive images What are responsive images? ▸ RICG ▸ <picture> ▸ srcset=“”sizes=“”
  • 14. Responsive images srcset and sizes ▸ Used to save bandwidth ▸ Appropriate image size depending on context ▸ Browser has final control
  • 15. Responsive images srcset <img src="small.jpg" srcset="large.jpg 1024w, medium.jpg 640w, small.jpg 320w" alt="A tasty potato"> Example 1 Viewport width = 320px
 Pixel density = 1
 Chosen image* = small.jpg Example 2 Viewport width = 320px
 Pixel density = 2
 Chosen image* = medium.jpg * Probably! (the browser decides)
  • 16. Responsive images sizes ‣ Tells browser the width that the image will be displayed
  • 17. Responsive images sizes <img src="small.jpg" srcset="large.jpg 1024w, medium.jpg 640w, small.jpg 320w" sizes="33.3vw" alt="A tasty potato">
  • 18. Responsive images sizes <img src="small.jpg" srcset="large.jpg 1024w, medium.jpg 640w, small.jpg 320w" sizes="33.3vw" alt="A tasty potato">
  • 20. Responsive images sizes <img src="small.jpg" srcset="large.jpg 1024w, medium.jpg 640w, small.jpg 320w" sizes=“(min-width: 640px) 33.3vw, 100vw” alt="A tasty potato">
  • 22. Responsive images Responsive images in WordPress ▸ Started with the plugin from RICG ▸ Added to core in 4.4 ▸ Adds srcset and sizes support to content images ▸ New functions ▸ New default image size (‘medium_large’) 768px w ▸ No <picture> support
  • 23. Responsive images Using responsive images in your theme $img = get_field(‘image’); // get image from ACF field $img_id = $img['ID'];
 $img_src = $img['sizes']['archive'];
 $img_meta = wp_get_attachment_metadata($img_id); $image_html = '<img src="'.$img_src.'" alt="'.$img['alt'].'" />’; echo wp_image_add_srcset_and_sizes ( $image_html, $img_meta, $img_id );
  • 24. Responsive images Using responsive images in your theme Result <img src="http://potato-passion.com/media/potato-on-table-282x212.jpg" alt="" srcset=“http://potato-passion.com/media/potato-on-table-300x225.jpg 300w, http://potato-passion.com/media/potato-on-table-768x576.jpg 768w, http://potato-passion.com/media/potato-on-table-1600x1200.jpg 1600w, http://potato-passion.com/media/potato-on-table-770x578.jpg 770w, http://potato-passion.com/media/potato-on-table-282x212.jpg 282w, sizes="(max-width: 282px) 100vw, 282px">
  • 25. Responsive images Using responsive images in your theme Other thoughts ▸ Customise the ‘sizes’ output using wp_calculate_image_sizes() filter ▸ Default is better than nothing
  • 26. Responsive images wp-lazysizes ▸ The daddy of image plugins ▸ Lazy loading AND responsive images ▸ Works out ‘sizes’ attribute for you ▸ https://github.com/aFarkas/wp-lazysizes ▸ Caveat: I haven’t used this in production yet!
  • 27. Summary What did we learn? ▸ We have an image problem ▸ We have the tools to solve it! ▸ Optimise your images ▸ Lazy-load your images ▸ Use responsive images