SlideShare a Scribd company logo
1 of 80
Download to read offline
Building faster websites
Web performance with WordPress
Johannes Siipola / Wordpress Meetup Helsinki 4.4.2018
Why web performance matters
Web performance with WordPress
Why web performance matters
Web performance with WordPress
Why performance matters
• Web page size and complexity is increasing every year
• More and more people are browsing the web on phones and 3g connections
• You need to have empathy for your users. Not everyone is visiting your site
on a MacBook pro with a fiber optic connection
Why web performance matters
Web performance with WordPress
Performance business impact
• More performance means happier users
• Google’s research says that 50% of users abandon site if it takes more than 3
seconds to load
• Fast loading increases conversions and revenue, can improve your SEO
• For more statistics visit https://wpostats.com
Web server performance
Web performance with WordPress
Use a VPS or Managed
WordPress hosting instead of
shared hosting
Web performance with WordPress
Web server performance / Upgrade your hosting
Web performance with WordPress
Shared hosting
• Slow performance
• Often no caching on the server level
• Limited configuration options
Web server performance / Upgrade your hosting
Web performance with WordPress
VPS (Virtual Private Server)
• You can configure it however you like
• Server side caching, Gzip, Expires…
• You need sysadmin skills (or hire someone who does)
Web server performance / Upgrade your hosting
Web performance with WordPress
Managed WordPress hosting
• WP-Palvelu, WP Engine, WordPress VIP, Kinsta, Pantheon…
• Optimized for WordPress
• Very little configuration options
• Optimized for performance: Server side caching, CDN, HTTP2, Gzip
Caching
Web performance with WordPress
Web server performance / Caching
Web performance with WordPress
Time to first byte
• Time to first byte: how much server processing and network latency before
first byte is transferred
• Critical because no other resources can be downloaded before this is done
Web server performance / Caching
Web performance with WordPress
Caching
• Generating page in WordPress is slow: you need to process PHP, do SQL
queries
• Caching generates static copies of your pages and bypasses all this
• Don’t optimise you code, just add caching
Web server performance / Caching
Web performance with WordPress
Why cache?
• In addition to speed, caching is also important for scalability. If you end up
on the front page of Reddit with no caching, most servers won’t be able to
handle it if all requests go to WordPress
Web server performance / Caching
Web performance with WordPress
Cache plugins
• Caching is most effective when implemented server side: Nginx, Varnish
• There are dozens of caching plugins for WordPress: W3 Total Cache, WP Super Cache etc.
• By default cache plugins still execute PHP - bad
• In some plugins you can configure enhanced caching so cached pages are server by web
server instead of PHP
• At least it’s better than nothing
Web server performance / Caching
Web performance with WordPress
Caching problems
• Caching works well for blogs and news sites
• Problematic if your site has logged in users (non-admins), shopping carts, geolocation
• You can exclude pages from cache using paths or cookies or use cache bins to isolate by
geolocation or device type (mobile, desktop)
• Or use Javascript and AJAX to implement user-specific features
• Make sure to switch to a real cron if you use caching so your cron jobs run on time
Use HTTP/2
Web performance with WordPress
Web server performance / HTTP2
Web performance with WordPress
HTTP/2
• Browsers communicate with servers using HTTP protocol
• HTTP/2 is the latest version of the protocol
• Allows connection multiplexing and HTTP header compression
• Supported in recent Nginx and Apache versions - but you need HTTPS
Use compression
Web performance with WordPress
Web server performance / Compression
Web performance with WordPress
Compression
• Makes resources smaller by formatting them differently
• Text files like HTML, CSS and JS compress well, images or files don’t
• Gzip compression is supported by all browsers since IE6
• Enable in Nginx or Apache and it just works
Optimize asset delivery
Web performance with WordPress
Don’t load unnessary resources
Web performance with WordPress
Optimize asset delivery / Don’t load unnessary resources
Web performance with WordPress
Don’t load unnessary resources
• Less resources, faster the site
• Don’t load anything you don’t use
• Disable plugins you don’t use
Optimize asset delivery / Don’t load unnessary resources
Web performance with WordPress
Don’t load unnessary resources
• Audit your CSS with unCSS
• If you use Bootstrap or Foundation, use sass to comment out parts you don’t
use
• Avoid using ready-made themes or plugins with front end dependencies
• Don’t use a plugin if you don’t have to
Minify assets
Web performance with WordPress
Optimize asset delivery / Minify assets
Web performance with WordPress
What is minification?
• CSS and js files contain data that is useful to humans but not computers
• Minification makes files smaller but doesn’t change it’s meaning
• Use Source maps to debug minified files in production
Optimize asset delivery / Minify assets
Web performance with WordPress
How to minify?
• Use UglifyJS for JavaScript files
• Use Clean CSS or CSSNano for CSS files
• These are command line tools you can integrate into your workflow using
Gulp or Webpack
Optimize asset delivery / Minify assets
Web performance with WordPress
What about files added by plugins?
• You can use Autoptimize plugin to automatically minify and bundle assets
added by themes or plugins
• Exclude your own files if you want the source maps to work
Cache assets
Web performance with WordPress
Optimize asset delivery / Cache assets
Web performance with WordPress
Cache assets
• When browser downloads an asset like image, CSS or JavaScript file, it’s
cached in the browser
• Loading file from cache is much faster than downloading it again
• Caching in controlled according to cache control HTTP headers sent by the
server
Optimize asset delivery / Cache assets
Web performance with WordPress
How to set cache control headers?
• Cache control is configured in server settings: nginx.conf or .htaccess
• For example configurations, go to https://github.com/h5bp/server-configs
• Some plugins like W3 total cache can write these config files for you
Optimize asset delivery / Cache assets
Web performance with WordPress
Cache busting
• Expires are great for performance but if CSS and JavaScript files are updated
but user have older versions in their cache, it can break your site
• This can be fixed by changing the file every time the file is updated
• With cache busting, you can use far future expires, cache assets up to a year
Optimize asset delivery / Cache assets
Web performance with WordPress
Cache busting strategies
• File version like /style.css?v=1 and /style.css?v=2 is simple but easy to
forget
• Modification date: /style.css?v=1522515085
• Hash: /style.css?v=5f4dcc3b5aa765d61d8327deb882cf99
Optimize asset delivery / Cache assets
Web performance with WordPress
Where to put the hash?
• Query string /style.css?v=5f4dcc3b5aa765d61d8327deb882cf99 works
great in most cases, no changes to the server configuration
• File name /style.5f4dcc3b5aa765d61d8327deb882cf99.css is sometimes
needed but you need to either change the file names or use a rewrite to
redirect hashed url to the file on the disk
Optimize asset delivery / Cache assets
Web performance with WordPress
Content Delivery Network
(CDN)
Web performance with WordPress
Optimize asset delivery / CDN
Web performance with WordPress
Why do need CDNs?
• Your servers are located in one place but your site might have users from all
over the world
• Further the users are located from your servers, more latency will incur
Optimize asset delivery / CDN
Web performance with WordPress
What is a CDN?
• CDN is geographically distributed cache that serves content close to your
users
• Most CDNs only cache static content
Optimize asset delivery / CDN
Web performance with WordPress
Do I need a CDN?
• If you have visitors from all over the world, CDN can improve the experience
for your users
• If you have visitors mostly from one country and servers are located close by,
there is no need for a CDN
Optimize asset delivery / CDN
Web performance with WordPress
How to use CDN
• Sign up for a CDN and enter your origin URL
• Just change the assets paths
• CDN enabler plugin from KeyCDN
• Some caching plugins like W3 total cache have CDN support built in
Optimize images
Web performance with WordPress
Responsive images
Web performance with WordPress
Optimize asset delivery / Optimize images
Web performance with WordPress
Responsive images
• High resolution screens on devices like phones and Retina Macs
• Normal resolution images look bad on high res screens
• Doubling the image resolution is wasteful for normal resolution displays
• Responsive images with scrset and sizes solve this problem. Serve right
image to the right screen
Optimize asset delivery / Optimize images
Web performance with WordPress
How to use responsive images?
• Srcset is the standard for responsive images
• Srcset support is baked into WordPress since 4.4 - but just for images in the
content area
Optimize asset delivery / Optimize images
Web performance with WordPress
Optimize asset delivery / Optimize images
Web performance with WordPress
How to use responsive images?
• Set the content area width using wp_calculate_image_sizes filter
• You might want to add new images using add_image_size()
Optimize asset delivery / Optimize images
Web performance with WordPress
Optimize image file size
Web performance with WordPress
Optimize asset delivery / Optimize images
Web performance with WordPress
Optimize image file size
• Use correct file types
• JPEG for photos
• PNG or SVG for charts and graphics
Optimize asset delivery / Optimize images
Web performance with WordPress
Optimize image file size
• Photoshop’s Save for web and WordPress’s GD or ImageMagic resizing don’t output
particularly optimised images
• Tools like MozJPEG and PNGQUANT can optimize files even more with minimal quality loss
• Remove image metadata like camera model or geo coordinates
• Chroma subsampling takes advantage how human eye works, it can save up to 20% in file
size
Optimize asset delivery / Optimize images
Web performance with WordPress
Progressive JPEGs
• By encoding images as progressive JPEGs, they are often smaller and load
by incrementally increasing resolution rather than from top to bottom - faster
perceived loading
Source:
http://bbshowcase.org/
progressive/
Optimize asset delivery / Optimize images
Web performance with WordPress
How to automate image compression?
• There is no single right quality setting because every image it different
• Nobody wants to fiddle with compression settings, upload best quality
images into WordPress and use a compression plugin to optimise images
automatically
Optimize asset delivery / Optimize images
Web performance with WordPress
Image optimization plugins
• WP Smush, kraken.io, optimus.io, EWWW.io, ShortPixel, Imagify
• SaaS services that optimise image on cloud servers - for a fee
• Also optimise image thumbnails
• If you use a plugin, set the WordPress thumbnail quality to 100 so you don’t
double compress your images
Optimize web fonts
Web performance with WordPress
Optimize asset delivery / Optimize web fonts
Web performance with WordPress
Optimize Web fonts
• Load as few typefaces and font weights as possible
• Use latest formats like WOFF2
• Subset fonts (check the license beforehand!)
• Preload most critical fonts to avoid FOIT
Web performance with WordPress
Optimize JavaScript loading
Web performance with WordPress
Optimize asset delivery / Optimize JavaScript loading
Web performance with WordPress
Optimize JavaScript loading
• Most of the time, JavaScript is not needed for the initial view to load.
• Script tags in the header are parser blocking
• Avoid blocking by putting script tags at the bottom
Web performance with WordPress
Optimize asset delivery / Optimize JavaScript
Web performance with WordPress
Optimize JavaScript
• Some plugins add scripts to document head but you can use Scripts to
footer plugin to force them to footer
• Some scripts in the head like Google Analytics are actually asynchronous so
they don’t benefit from moving them to the footer
Optimize CSS loading
Web performance with WordPress
Optimize asset delivery / Optimize CSS loading
Web performance with WordPress
Optimize CSS loading
• Google recommends inlining critical CSS and deferring rest - but this only
works for simple and static sites
• Split CSS based on page templates or elements, this way you don’t load
unnessary CSS rules on a page.
Web performance tools
Web performance with WordPress
Auditing tools
Web performance with WordPress
Web performance tools / Auditing tools
Web performance with WordPress
Browser developer tools
• Browser timeline tool is your best friend to see what resources are being
loaded and how fast
• Latest versions of Chrome also include auditing tool you can use to measure
your site performance
Web performance tools / Auditing tools
Web performance with WordPress
Google PageSpeed Insights
• Scans your page, assigns a score and offers performance improvement
suggestions
• PageSpeed score is a meaningless number - focus of fast site rather than
high score
• PSI nowadays also offers RUM statistics in addition to synthetic score
Web performance tools / Auditing tools
Web performance with WordPress
WebPageTest
• Loads your site in real / VM browser from locations all around the world
• Waterfall charts, timelines, video recordings, speed scores
• Can also emulate mobile browsers, different network conditions
Monitoring tools
Web performance with WordPress
Web performance tools / Monitoring tools
Web performance with WordPress
Pingdom
• Monitor real life loading times from all over the world
• Compare desktop and mobile browsers
• Can also do synthetic benchmarks over time
Web performance tools / Monitoring tools
Web performance with WordPress
New Relic
• Similar to Pingdom with additional features, for example monitoring for
AJAX and SPA applications - but more expensive
• New Relic also offers APM tool that you can use to monitor WordPress
backend performance
How to get started with web
performance optimization?
Web performance with WordPress
1. Audit your site using

PageSpeed insights /
WebPageTest
Web performance with WordPress
2. Follow suggestions, start with
easy wins like minification, GZIP,
image optimisation and HTTP2
Web performance with WordPress
3. Monitor performance over
time
Web performance with WordPress
4. Consider advanced
performance techiques
Web performance with WordPress
Thank you! Questions?
Web performance with WordPress

More Related Content

What's hot

Web Application Optimization Techniques
Web Application Optimization TechniquesWeb Application Optimization Techniques
Web Application Optimization Techniques
takinbo
 
Improving Website Performance and Scalability with Memcached
Improving Website Performance and Scalability with MemcachedImproving Website Performance and Scalability with Memcached
Improving Website Performance and Scalability with Memcached
Acquia
 
20130714 php matsuri - highly available php
20130714   php matsuri - highly available php20130714   php matsuri - highly available php
20130714 php matsuri - highly available php
Graham Weldon
 

What's hot (20)

Web Application Optimization Techniques
Web Application Optimization TechniquesWeb Application Optimization Techniques
Web Application Optimization Techniques
 
The Power of a Video Library - WordCamp Raleigh
The  Power of a Video Library - WordCamp RaleighThe  Power of a Video Library - WordCamp Raleigh
The Power of a Video Library - WordCamp Raleigh
 
Why your slow loading website is costing you sales and how to fix it
Why your slow loading website is costing you sales and how to fix itWhy your slow loading website is costing you sales and how to fix it
Why your slow loading website is costing you sales and how to fix it
 
Why your slow loading website is costing you sales and how to fix it
Why your slow loading website is costing you sales and how to fix itWhy your slow loading website is costing you sales and how to fix it
Why your slow loading website is costing you sales and how to fix it
 
CIRCUIT 2015 - Akamai: Caching and Beyond
CIRCUIT 2015 - Akamai:  Caching and BeyondCIRCUIT 2015 - Akamai:  Caching and Beyond
CIRCUIT 2015 - Akamai: Caching and Beyond
 
Imagine 2014: The Devil is in the Details How to Optimize Magento Hosting to ...
Imagine 2014: The Devil is in the Details How to Optimize Magento Hosting to ...Imagine 2014: The Devil is in the Details How to Optimize Magento Hosting to ...
Imagine 2014: The Devil is in the Details How to Optimize Magento Hosting to ...
 
CQ5.x Maintenance Webinar 2013
CQ5.x Maintenance Webinar 2013CQ5.x Maintenance Webinar 2013
CQ5.x Maintenance Webinar 2013
 
Drupal 7 performance and optimization
Drupal 7 performance and optimizationDrupal 7 performance and optimization
Drupal 7 performance and optimization
 
Ui perf
Ui perfUi perf
Ui perf
 
CIRCUIT 2015 - Monitoring AEM
CIRCUIT 2015 - Monitoring AEMCIRCUIT 2015 - Monitoring AEM
CIRCUIT 2015 - Monitoring AEM
 
Memcached: What is it and what does it do? (PHP Version)
Memcached: What is it and what does it do? (PHP Version)Memcached: What is it and what does it do? (PHP Version)
Memcached: What is it and what does it do? (PHP Version)
 
Improving Website Performance and Scalability with Memcached
Improving Website Performance and Scalability with MemcachedImproving Website Performance and Scalability with Memcached
Improving Website Performance and Scalability with Memcached
 
Wordpress optimization
Wordpress optimizationWordpress optimization
Wordpress optimization
 
20130714 php matsuri - highly available php
20130714   php matsuri - highly available php20130714   php matsuri - highly available php
20130714 php matsuri - highly available php
 
Webinar: Adobe Experience Manager Clustering Made Easy on MongoDB
Webinar: Adobe Experience Manager Clustering Made Easy on MongoDB Webinar: Adobe Experience Manager Clustering Made Easy on MongoDB
Webinar: Adobe Experience Manager Clustering Made Easy on MongoDB
 
PAC 2019 virtual Mark Tomlinson
PAC 2019 virtual Mark TomlinsonPAC 2019 virtual Mark Tomlinson
PAC 2019 virtual Mark Tomlinson
 
React.js for Rails Developers
React.js for Rails DevelopersReact.js for Rails Developers
React.js for Rails Developers
 
Breaking the Speed Limit: Faster Websites Win
Breaking the Speed Limit: Faster Websites WinBreaking the Speed Limit: Faster Websites Win
Breaking the Speed Limit: Faster Websites Win
 
React on rails v6.1 at LA Ruby, November 2016
React on rails v6.1 at LA Ruby, November 2016React on rails v6.1 at LA Ruby, November 2016
React on rails v6.1 at LA Ruby, November 2016
 
Client-side Website Optimization
Client-side Website OptimizationClient-side Website Optimization
Client-side Website Optimization
 

Similar to Building faster websites: web performance with WordPress

How to Speed Up Your Joomla! Site
How to Speed Up Your Joomla! SiteHow to Speed Up Your Joomla! Site
How to Speed Up Your Joomla! Site
Daniel Kanchev
 

Similar to Building faster websites: web performance with WordPress (20)

Caching 101
Caching 101Caching 101
Caching 101
 
Optimizing Your WordPress Site: Why speed matters, and how to get there
Optimizing Your WordPress Site: Why speed matters, and how to get thereOptimizing Your WordPress Site: Why speed matters, and how to get there
Optimizing Your WordPress Site: Why speed matters, and how to get there
 
Squeeze Maximum Performance From Your Joomla Website
Squeeze Maximum Performance From Your Joomla WebsiteSqueeze Maximum Performance From Your Joomla Website
Squeeze Maximum Performance From Your Joomla Website
 
WordPress at Peak Performance (Radio Edit)
WordPress at Peak Performance (Radio Edit)WordPress at Peak Performance (Radio Edit)
WordPress at Peak Performance (Radio Edit)
 
I Can Haz More Performanz?
I Can Haz More Performanz?I Can Haz More Performanz?
I Can Haz More Performanz?
 
Custom coded projects
Custom coded projectsCustom coded projects
Custom coded projects
 
Introduction to Optimizing WordPress for Website Speed
Introduction to Optimizing WordPress for Website SpeedIntroduction to Optimizing WordPress for Website Speed
Introduction to Optimizing WordPress for Website Speed
 
WordPress Hosting Best Practices - Do's and Don't s | WordPress Trivandrum
WordPress Hosting Best Practices - Do's and Don't s  | WordPress TrivandrumWordPress Hosting Best Practices - Do's and Don't s  | WordPress Trivandrum
WordPress Hosting Best Practices - Do's and Don't s | WordPress Trivandrum
 
Web performance
Web performanceWeb performance
Web performance
 
10 Tips for Optimising WordPress
10 Tips for Optimising WordPress10 Tips for Optimising WordPress
10 Tips for Optimising WordPress
 
Enterprise WordPress - Performance, Scalability and Redundancy
Enterprise WordPress - Performance, Scalability and RedundancyEnterprise WordPress - Performance, Scalability and Redundancy
Enterprise WordPress - Performance, Scalability and Redundancy
 
WordPress At Scale. WordCamp Dhaka 2019
WordPress At Scale. WordCamp Dhaka 2019WordPress At Scale. WordCamp Dhaka 2019
WordPress At Scale. WordCamp Dhaka 2019
 
How to Speed Up Your Joomla! Site
How to Speed Up Your Joomla! SiteHow to Speed Up Your Joomla! Site
How to Speed Up Your Joomla! Site
 
Improve WordPress performance with caching and deferred execution of code
Improve WordPress performance with caching and deferred execution of codeImprove WordPress performance with caching and deferred execution of code
Improve WordPress performance with caching and deferred execution of code
 
Learn WordPress - Live Session 2 Slides
Learn WordPress - Live Session 2 SlidesLearn WordPress - Live Session 2 Slides
Learn WordPress - Live Session 2 Slides
 
Optimizing WordPress Performance
Optimizing WordPress PerformanceOptimizing WordPress Performance
Optimizing WordPress Performance
 
How do you speed up your (Wordpress) website?
How do you speed up your (Wordpress) website?How do you speed up your (Wordpress) website?
How do you speed up your (Wordpress) website?
 
Guide 4 - How To Dramatically Speed Up Your Website Using A Caching Plugin.pdf
Guide 4 - How To Dramatically Speed Up Your Website Using A Caching Plugin.pdfGuide 4 - How To Dramatically Speed Up Your Website Using A Caching Plugin.pdf
Guide 4 - How To Dramatically Speed Up Your Website Using A Caching Plugin.pdf
 
Minimize website page loading time – 20+ advanced SEO tips
Minimize website page loading time – 20+ advanced SEO tipsMinimize website page loading time – 20+ advanced SEO tips
Minimize website page loading time – 20+ advanced SEO tips
 
The 5 most common reasons for a slow WordPress site and how to fix them – ext...
The 5 most common reasons for a slow WordPress site and how to fix them – ext...The 5 most common reasons for a slow WordPress site and how to fix them – ext...
The 5 most common reasons for a slow WordPress site and how to fix them – ext...
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
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)
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
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...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
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
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
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
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 

Building faster websites: web performance with WordPress

  • 1. Building faster websites Web performance with WordPress Johannes Siipola / Wordpress Meetup Helsinki 4.4.2018
  • 2. Why web performance matters Web performance with WordPress
  • 3. Why web performance matters Web performance with WordPress Why performance matters • Web page size and complexity is increasing every year • More and more people are browsing the web on phones and 3g connections • You need to have empathy for your users. Not everyone is visiting your site on a MacBook pro with a fiber optic connection
  • 4. Why web performance matters Web performance with WordPress Performance business impact • More performance means happier users • Google’s research says that 50% of users abandon site if it takes more than 3 seconds to load • Fast loading increases conversions and revenue, can improve your SEO • For more statistics visit https://wpostats.com
  • 5. Web server performance Web performance with WordPress
  • 6. Use a VPS or Managed WordPress hosting instead of shared hosting Web performance with WordPress
  • 7. Web server performance / Upgrade your hosting Web performance with WordPress Shared hosting • Slow performance • Often no caching on the server level • Limited configuration options
  • 8. Web server performance / Upgrade your hosting Web performance with WordPress VPS (Virtual Private Server) • You can configure it however you like • Server side caching, Gzip, Expires… • You need sysadmin skills (or hire someone who does)
  • 9. Web server performance / Upgrade your hosting Web performance with WordPress Managed WordPress hosting • WP-Palvelu, WP Engine, WordPress VIP, Kinsta, Pantheon… • Optimized for WordPress • Very little configuration options • Optimized for performance: Server side caching, CDN, HTTP2, Gzip
  • 11. Web server performance / Caching Web performance with WordPress Time to first byte • Time to first byte: how much server processing and network latency before first byte is transferred • Critical because no other resources can be downloaded before this is done
  • 12. Web server performance / Caching Web performance with WordPress Caching • Generating page in WordPress is slow: you need to process PHP, do SQL queries • Caching generates static copies of your pages and bypasses all this • Don’t optimise you code, just add caching
  • 13. Web server performance / Caching Web performance with WordPress Why cache? • In addition to speed, caching is also important for scalability. If you end up on the front page of Reddit with no caching, most servers won’t be able to handle it if all requests go to WordPress
  • 14. Web server performance / Caching Web performance with WordPress Cache plugins • Caching is most effective when implemented server side: Nginx, Varnish • There are dozens of caching plugins for WordPress: W3 Total Cache, WP Super Cache etc. • By default cache plugins still execute PHP - bad • In some plugins you can configure enhanced caching so cached pages are server by web server instead of PHP • At least it’s better than nothing
  • 15. Web server performance / Caching Web performance with WordPress Caching problems • Caching works well for blogs and news sites • Problematic if your site has logged in users (non-admins), shopping carts, geolocation • You can exclude pages from cache using paths or cookies or use cache bins to isolate by geolocation or device type (mobile, desktop) • Or use Javascript and AJAX to implement user-specific features • Make sure to switch to a real cron if you use caching so your cron jobs run on time
  • 16. Use HTTP/2 Web performance with WordPress
  • 17. Web server performance / HTTP2 Web performance with WordPress HTTP/2 • Browsers communicate with servers using HTTP protocol • HTTP/2 is the latest version of the protocol • Allows connection multiplexing and HTTP header compression • Supported in recent Nginx and Apache versions - but you need HTTPS
  • 19. Web server performance / Compression Web performance with WordPress Compression • Makes resources smaller by formatting them differently • Text files like HTML, CSS and JS compress well, images or files don’t • Gzip compression is supported by all browsers since IE6 • Enable in Nginx or Apache and it just works
  • 20. Optimize asset delivery Web performance with WordPress
  • 21. Don’t load unnessary resources Web performance with WordPress
  • 22. Optimize asset delivery / Don’t load unnessary resources Web performance with WordPress Don’t load unnessary resources • Less resources, faster the site • Don’t load anything you don’t use • Disable plugins you don’t use
  • 23. Optimize asset delivery / Don’t load unnessary resources Web performance with WordPress Don’t load unnessary resources • Audit your CSS with unCSS • If you use Bootstrap or Foundation, use sass to comment out parts you don’t use • Avoid using ready-made themes or plugins with front end dependencies • Don’t use a plugin if you don’t have to
  • 25. Optimize asset delivery / Minify assets Web performance with WordPress What is minification? • CSS and js files contain data that is useful to humans but not computers • Minification makes files smaller but doesn’t change it’s meaning • Use Source maps to debug minified files in production
  • 26. Optimize asset delivery / Minify assets Web performance with WordPress How to minify? • Use UglifyJS for JavaScript files • Use Clean CSS or CSSNano for CSS files • These are command line tools you can integrate into your workflow using Gulp or Webpack
  • 27. Optimize asset delivery / Minify assets Web performance with WordPress What about files added by plugins? • You can use Autoptimize plugin to automatically minify and bundle assets added by themes or plugins • Exclude your own files if you want the source maps to work
  • 29. Optimize asset delivery / Cache assets Web performance with WordPress Cache assets • When browser downloads an asset like image, CSS or JavaScript file, it’s cached in the browser • Loading file from cache is much faster than downloading it again • Caching in controlled according to cache control HTTP headers sent by the server
  • 30. Optimize asset delivery / Cache assets Web performance with WordPress How to set cache control headers? • Cache control is configured in server settings: nginx.conf or .htaccess • For example configurations, go to https://github.com/h5bp/server-configs • Some plugins like W3 total cache can write these config files for you
  • 31. Optimize asset delivery / Cache assets Web performance with WordPress Cache busting • Expires are great for performance but if CSS and JavaScript files are updated but user have older versions in their cache, it can break your site • This can be fixed by changing the file every time the file is updated • With cache busting, you can use far future expires, cache assets up to a year
  • 32. Optimize asset delivery / Cache assets Web performance with WordPress Cache busting strategies • File version like /style.css?v=1 and /style.css?v=2 is simple but easy to forget • Modification date: /style.css?v=1522515085 • Hash: /style.css?v=5f4dcc3b5aa765d61d8327deb882cf99
  • 33. Optimize asset delivery / Cache assets Web performance with WordPress Where to put the hash? • Query string /style.css?v=5f4dcc3b5aa765d61d8327deb882cf99 works great in most cases, no changes to the server configuration • File name /style.5f4dcc3b5aa765d61d8327deb882cf99.css is sometimes needed but you need to either change the file names or use a rewrite to redirect hashed url to the file on the disk
  • 34. Optimize asset delivery / Cache assets Web performance with WordPress
  • 35. Content Delivery Network (CDN) Web performance with WordPress
  • 36. Optimize asset delivery / CDN Web performance with WordPress Why do need CDNs? • Your servers are located in one place but your site might have users from all over the world • Further the users are located from your servers, more latency will incur
  • 37.
  • 38.
  • 39. Optimize asset delivery / CDN Web performance with WordPress What is a CDN? • CDN is geographically distributed cache that serves content close to your users • Most CDNs only cache static content
  • 40. Optimize asset delivery / CDN Web performance with WordPress Do I need a CDN? • If you have visitors from all over the world, CDN can improve the experience for your users • If you have visitors mostly from one country and servers are located close by, there is no need for a CDN
  • 41. Optimize asset delivery / CDN Web performance with WordPress How to use CDN • Sign up for a CDN and enter your origin URL • Just change the assets paths • CDN enabler plugin from KeyCDN • Some caching plugins like W3 total cache have CDN support built in
  • 43.
  • 45. Optimize asset delivery / Optimize images Web performance with WordPress Responsive images • High resolution screens on devices like phones and Retina Macs • Normal resolution images look bad on high res screens • Doubling the image resolution is wasteful for normal resolution displays • Responsive images with scrset and sizes solve this problem. Serve right image to the right screen
  • 46. Optimize asset delivery / Optimize images Web performance with WordPress How to use responsive images? • Srcset is the standard for responsive images • Srcset support is baked into WordPress since 4.4 - but just for images in the content area
  • 47. Optimize asset delivery / Optimize images Web performance with WordPress
  • 48. Optimize asset delivery / Optimize images Web performance with WordPress How to use responsive images? • Set the content area width using wp_calculate_image_sizes filter • You might want to add new images using add_image_size()
  • 49. Optimize asset delivery / Optimize images Web performance with WordPress
  • 50. Optimize image file size Web performance with WordPress
  • 51. Optimize asset delivery / Optimize images Web performance with WordPress Optimize image file size • Use correct file types • JPEG for photos • PNG or SVG for charts and graphics
  • 52. Optimize asset delivery / Optimize images Web performance with WordPress Optimize image file size • Photoshop’s Save for web and WordPress’s GD or ImageMagic resizing don’t output particularly optimised images • Tools like MozJPEG and PNGQUANT can optimize files even more with minimal quality loss • Remove image metadata like camera model or geo coordinates • Chroma subsampling takes advantage how human eye works, it can save up to 20% in file size
  • 53. Optimize asset delivery / Optimize images Web performance with WordPress Progressive JPEGs • By encoding images as progressive JPEGs, they are often smaller and load by incrementally increasing resolution rather than from top to bottom - faster perceived loading
  • 55. Optimize asset delivery / Optimize images Web performance with WordPress How to automate image compression? • There is no single right quality setting because every image it different • Nobody wants to fiddle with compression settings, upload best quality images into WordPress and use a compression plugin to optimise images automatically
  • 56. Optimize asset delivery / Optimize images Web performance with WordPress Image optimization plugins • WP Smush, kraken.io, optimus.io, EWWW.io, ShortPixel, Imagify • SaaS services that optimise image on cloud servers - for a fee • Also optimise image thumbnails • If you use a plugin, set the WordPress thumbnail quality to 100 so you don’t double compress your images
  • 57. Optimize web fonts Web performance with WordPress
  • 58. Optimize asset delivery / Optimize web fonts Web performance with WordPress Optimize Web fonts • Load as few typefaces and font weights as possible • Use latest formats like WOFF2 • Subset fonts (check the license beforehand!) • Preload most critical fonts to avoid FOIT
  • 59. Web performance with WordPress
  • 60. Optimize JavaScript loading Web performance with WordPress
  • 61. Optimize asset delivery / Optimize JavaScript loading Web performance with WordPress Optimize JavaScript loading • Most of the time, JavaScript is not needed for the initial view to load. • Script tags in the header are parser blocking • Avoid blocking by putting script tags at the bottom
  • 62. Web performance with WordPress
  • 63. Optimize asset delivery / Optimize JavaScript Web performance with WordPress Optimize JavaScript • Some plugins add scripts to document head but you can use Scripts to footer plugin to force them to footer • Some scripts in the head like Google Analytics are actually asynchronous so they don’t benefit from moving them to the footer
  • 64. Optimize CSS loading Web performance with WordPress
  • 65. Optimize asset delivery / Optimize CSS loading Web performance with WordPress Optimize CSS loading • Google recommends inlining critical CSS and deferring rest - but this only works for simple and static sites • Split CSS based on page templates or elements, this way you don’t load unnessary CSS rules on a page.
  • 66. Web performance tools Web performance with WordPress
  • 68. Web performance tools / Auditing tools Web performance with WordPress Browser developer tools • Browser timeline tool is your best friend to see what resources are being loaded and how fast • Latest versions of Chrome also include auditing tool you can use to measure your site performance
  • 69. Web performance tools / Auditing tools Web performance with WordPress Google PageSpeed Insights • Scans your page, assigns a score and offers performance improvement suggestions • PageSpeed score is a meaningless number - focus of fast site rather than high score • PSI nowadays also offers RUM statistics in addition to synthetic score
  • 70.
  • 71. Web performance tools / Auditing tools Web performance with WordPress WebPageTest • Loads your site in real / VM browser from locations all around the world • Waterfall charts, timelines, video recordings, speed scores • Can also emulate mobile browsers, different network conditions
  • 73. Web performance tools / Monitoring tools Web performance with WordPress Pingdom • Monitor real life loading times from all over the world • Compare desktop and mobile browsers • Can also do synthetic benchmarks over time
  • 74. Web performance tools / Monitoring tools Web performance with WordPress New Relic • Similar to Pingdom with additional features, for example monitoring for AJAX and SPA applications - but more expensive • New Relic also offers APM tool that you can use to monitor WordPress backend performance
  • 75. How to get started with web performance optimization? Web performance with WordPress
  • 76. 1. Audit your site using
 PageSpeed insights / WebPageTest Web performance with WordPress
  • 77. 2. Follow suggestions, start with easy wins like minification, GZIP, image optimisation and HTTP2 Web performance with WordPress
  • 78. 3. Monitor performance over time Web performance with WordPress
  • 79. 4. Consider advanced performance techiques Web performance with WordPress
  • 80. Thank you! Questions? Web performance with WordPress