Overview
The following describes some advanced solutions to help you optimize slow or inefficient WordPress websites.
Professional Services assistance
If you need help optimizing your WordPress site, DreamHost's skilled support team may be able to assist you for a small fee. You can find more information about supported services and associated costs in the DreamHost Professional Services article.
Updating and configuring software
The first step you should take is to ensure you are running the most recent software.
Checking software versions
There are four main components you should pay attention to:
- WordPress core
- Website PHP version
- Plugins
- Themes
WordPress core
You can check the WordPress core version using the following methods:
- A banner displays at the top of the dashboard if you're using an outdated version.
- View the Updates section of the dashboard.
- View the version in the bottom right-hand corner of the wp-admin page.
- Log into your server via FTP or SSH and read the wp-includes/version.php file
- Log into your server via SSH and run the wp core version command.
Manually updating the version
If your site was created using the DreamHost WordPress installer or DreamPress, your site should receive automatic updates from DreamHost. However, you can manually update this at any time by following the instructions in this article.
Website PHP version
PHP is the coding language that WordPress is built upon, so you need to make sure your site is running the latest version of PHP that your plugins and theme are able to support. View this article for instructions on updating your site's PHP version.
Plugins and themes
Your theme and all plugins should also be using their latest version. While WordPress will notify you of any new plugin and theme versions, there are a few things you will need to remember:
- Premium (purchased) plugins and themes are NOT stored in the WordPress repository. You will need to download updates to these plugins from the marketplace where you purchased them.
- Some plugins and themes are considered abandoned and have not been updated in quite some time. These can still be downloaded from wordpress.org, but they may not be compatible with modern versions of WordPress.
View the following articles for instructions on updating your WordPress plugins and themes:
Configuring plugins and themes
After the versions are all up to date, you can now focus on configuring your plugins and theme so they run efficiently.
Uninstall redundant plugins
Uninstall any plugins that your site no longer needs.
Also, make sure that you are not using similar plugins that do the same thing (such as multiple image optimization plugins). Some plugins, such as Jetpack, include many different features, so you can disable the ones you don't need.
If you have multiple plugins performing the same service, test your site performance with each one separately to compare results.
Review your theme
Test your site using a default theme to obtain an effective benchmark of performance. Then, enable your chosen theme to see how the results differ.
Many themes, especially premium ones, include many extra features, which can require higher resource requirements and reduce site performance.
Compatibility
Plugins can sometimes conflict with one another. If you're seeing delays or issues with your site's loading time(s), try testing different combinations of your plugins together.
Checking WP-Cron
WP-Cron is a WordPress scheduling function used by an array of plugins. Each time a site page is loaded, WordPress checks an internal schedule to see if there are any events to run. Common scheduled events include backups or posts. If these are run at inopportune times, (such as a site backup during peak traffic hours), they can cause performance issues.
As such, it is recommended that you move scheduled events to your site's off-peak hours. If your plugins do not have settings to individually manage their scheduled tasks, you can use a plugin like WP Crontrol to add, remove, manually run, and reschedule scheduled events.
Another potential issue can occur on particularly busy sites, where WordPress is continually checking its schedule to the point of causing performance issues. In these cases, it's recommended to disable WP-Cron and set up a system cron to handle task scheduling instead.
Optimizing
Testing the site’s performance
The following options help test the performance of your site.
Online tools — Online testing tools can offer suggestions on ways to improve your site, but be aware that the ranking these sites use is effectively arbitrary. If you do decide to use a speed-testing tool, make sure you use the same one throughout testing.
Plugin — You can also use a plugin like Query Monitor to test performance within the WordPress dashboard. This is more involved than using an online testing tool, but these plugins can access the back end of the site to provide more specific information.
Command line — You can also troubleshoot by logging into your server via SSH and using wp-cli. This allows you to debug and test directly on the server but requires more experience than other methods.
Optimizing images
Reducing the size of images can help to optimize your site. These can include backgrounds, icons, calls to action, avatars, and more. You can also consider using the EWWW Image Optimizer, which provides specific tools for this.
The following are several different ways to optimize your site's images.
Filetype
You should consider what file type to use for your site's images. The ideal choice can vary based on the purpose but often include:
- JPG — uses lossy compression, which reduces the image quality in exchange for a smaller file size. These are often used for photographs and smaller-scale images that can afford the drop in quality.
- PNG — uses lossless compression and is often used for highly detailed images like photographs. This means each image's quality is much better, but its file size is greatly increased compared to a JPG. These should only be used in situations where a high-quality image is required or images that use transparency.
- GIF — are smaller and lower quality than JPGs but support animations. Be aware of the file size and make sure it isn't so large that it slows down your web page's loading times.
- SVG — are vector-based graphics, which scale to any size without a loss in quality. Its file size will increase the more detailed they are, so they generally should only be used for logos or icons.
- WEBP — a modern format that supports lossy and lossless compression, animation, and transparency.
Size and scale
Consider resizing high-resolution images in an image editor. This is especially important when optimizing for mobile browsers, as smaller screens will be more impacted by larger file sizes.
Plugins
It's recommended that you use an image CDN such as Jetpack’s free Site Accelerator. The plugin can downsize your images when needed, convert them to WEBP format, and can be configured to use Lazy Loading. Another alternative is Imagify by WP Rocket, which offers many of the same features and includes a free option.
Lazy loading
Lazy loading delays loading an image element until it is actually visible in the viewport, reducing a visitor's initial load time. Several WordPress plugins offer this feature, including Jetpack, LazyLoad by WP Rocket, and a3 Lazy Load.
Minifying CSS/JS/HTML
Minification is the process of reducing the size of your static CSS, JS, and HTML files using two techniques.
Technique 1 — Minifying code
The first is removing the unnecessary parts of the file, such as comments and white space. For example, here’s a snippet of CSS code that has not been minified:
/* Applies to the entire body of the HTML document (except where overridden by more specific selectors). */ body { margin: 25px; background-color: rgb(240,240,240); font-family: arial, sans-serif; font-size: 14px; }
Once minified, the same code looks like this:
body{margin:25px;background-color:rgb(240,240,240);font-family:arial,sans-serif;font-size:14px;}
This is less human-readable, but the resulting file size is much smaller and will load faster. Since most users will not be interacting with static files, this is typically a good trade-off.
Technique 2 — Combining code
The second technique used in minification is combining multiple files of the same type into one file, which reduces the overall number of HTTP requests when loading the site.
Plugins
The following plugins can help to optimize your site.
- Jetpack’s Site Accelerator will minify static files but only covers assets from WordPress Core, WooCommerce, and Jetpack.
- Autoptimize is another option and covers all of your site's static files.
- Async JavaScript defers the parsing of JS files. This means that other site content, such as images and text, will load before the site's Javascript files. This can improve the browsing experience in many cases, but be aware that some themes rely on JS to render content, which may cause conflicts.
Caching
Caching is a simple and useful option to increase site performance.
- DreamPress — DreamPress sites use a server caching solution that is already configured as a part of the platform.
- WordPress — Standard WordPress installations have many different plugins available. Two common free recommendations are Cache Enabler and WP Super Cache.
Optimizing databases
See this article for more information about optimizing WordPress databases.
Managing traffic
Controlling traffic
If your site has already been optimized, but you're seeing a decrease in performance, check the HTTP requests hitting your server. You can find this information by checking your site's access logs.
This raw data is more reliable than analytics plugins when troubleshooting traffic.
View this article for several different commands you can use to sort and view the log data. For example, you can run the following command to count the number of times each IP has hit your site:
[server]$ awk '{print $1}' /path/to/your/access.log | sort | uniq -c |sort -n
Once you have a list of IPs, use a tool to lookup the IP address and determine if any additional actions need to be taken.
Controlling bots and crawlers
Search engine indexing bots and crawlers are important for SEO, but they can sometimes be aggressive, to the point of impacting site performance. See this article for information on limiting bots and crawlers.
Blocking traffic
If a high-traffic IP is not a known bot or crawler or a third-party service you’re using (such as a backup or CDN service), you may want to block it. View this article for information on blocking IPs using an .htaccess file.
Limiting /wp-admin/admin-ajax.php calls
The admin-ajax.php call, also known as the wp-admin heartbeat, sends a request every 15 seconds to keep the connection between the browser and the server alive. This allows for autosaves, prevents timeouts for users, and helps third-party plugin functions that are running in the background. However, each request loads the entirety of the /wp-admin page, which can increase resource usage. In some cases, admin-ajax.php can be called on the public-facing side of the site, usually due to a theme or plugin function.
If you see public-side admin-ajax.php calls, you can toggle your plugins off in a staging environment to find the culprit.
Another method of limiting the function is the Heartbeat Control plugin, which can disable admin-ajax calls on the public-facing and /wp-admin pages along with limiting post editor autosave frequency.
Using a CDN
A Content Delivery Network (CDN) can increase the performance of even a well-optimized site. Cloudflare is a free CDN option that includes multiple other features.
Additional steps
After you've gone through these optimization steps, you may find that your site still has performance issues. The first thing you should do is conduct an additional review of your plugins and themes. If you're not able to remove any additional plugins or use a less resource-intensive theme, you have two further options.
DreamHost's Site Optimization service
Consider using DreamHost's Site Optimization service. For more information about the service, see the following page:
Upgrade your hosting plan
Upgrading to DreamPress or VPS hosting could help if you're on a Shared Hosting plan, especially if you're expecting to see a growth in site traffic.