General WordPress optimization techniques

Over time, you may notice that your WordPress site runs slower or doesn't run as well as it should. There are several reasons this could occur. This article walks you through some of the most common issues and provides solutions to help you resolve them.

Online tools

Site load analyzation tools

First, use an online tool to analyze your website. You'll receive a breakdown of what may be causing your site to load slower than expected and it will give you insights to troubleshoot further.

Browser tools

Here are a few browser tools to help you troubleshoot performance issues with your WordPress site:

  • Firebug: A very handy tool that displays what is loading and how long it takes.
  • YSlow: A companion to Firebug that might give you some pointers on what to fix and how.
  • Web Inspector: Built into Chrome and Safari, it gives you much of the same information as Firebug.

Only use the following if you are using a VPS or Dedicated server:

  • Load Impact: A load testing service that hits your server with many simultaneous users. A free version does a 50 user test. Be sure that you have caching enabled before running. During this process, you can watch the CPU load with 'top', and RAM levels with 'free -m' - or both with 'vmstat 1' (Ctrl-c to stop).

Optimizing your database

Using the WP-DBManager plugin

You should routinely optimize your MySQL database to avoid a "fragmentation" effect. The easiest way to do this is to use the WP-DBManager plugin which includes a function to optimize your database as well as the capability to schedule this optimization to run at an appropriate time frame (recommended once per month at least).

Once installed, click 'Database' in the left pane.

WP-DBManager

Under 'Database', click 'Optimize DB'. Finally, click the 'Optimize' button.

Using wp-cli

wp-cli can also be used to optimize your database. Log into your server via SSH. Make sure you're in your WordPress site's directory, then run the following command to view all database command options:

[server]$ wp help db

To optimize the database, run the following:

[server]$ wp db optimize

Using SSH to optimize your database

View the following article for details on how to optimize the database via SSH:

Optimizing via phpMyAdmin

View the following article for details on how to optimize the database via phpMyAdmin:

Image Size

The size of your images is very often the cause of a slow loading site. The larger your images, the longer it will take for it to download on the user's end, so you'll want to make sure that your images are as small as possible while still preserving their quality. Please read over these instructions on how to optimize your images. You can also use a plugin such as:

Caching

PHP Cache

Enabling OPcache can help to improve PHP performance.

Using a caching plugin

Using a WordPress plugin to cache your data can also help. View the following article for further details:

Minify your scripts

You should also try to minify your HTML/CSS/JavaScript code as this can help shorten the time it takes your site to load. These types of plugins do not work however, so there's a little trial and error to find what works best for your site. Here are a few options:

Themes

Using a good theme can be challenging. While the ones on wordpress.org are free and safe to use, some are going to be better than others. When shopping for a theme, do some Google searches to see if people have complained about site speed with that theme. You'd be surprised what you find out.

A fast way to see if your theme is the problem is to change to the default theme (such as TwentySeventeen) and see if that helps your site.

  1. Log into your WordPress site's panel.
  2. On the left click 'Appearance > Themes'.
    WP_activate_theme
  3. Search for the default 'Twenty Seventeen' theme and click 'Activate'.

Your site will change its appearance to this new theme. Use the online tools above to check if this helped with your issue.

Making your theme Mobile Friendly

It's a very good idea to make sure your WordPress theme is mobile friendly. This helps to ensure all visitors (not just those on a desktop or laptop) will be able to view your site in an appropriate way for their mobile device. View the following link for further information:

Use a CDN to deliver static files

You can use a CDN to deliver static files such as images, video, CSS and JavaScript files. This can help speed up their delivery to the end user. View the following article for details on DreamHost's CDN and how to upload and link static files from DreamObjects.

Upgrading to DreamPress or a Private Server

If you've tried the plugins and suggestions but are still seeing a high load on the server, then it could be that the traffic to your site has outgrown shared hosting. At this point you may wish to consider adding a Private Server or DreamPress to your hosting package.

If you have any questions about adding DreamPress or a Private Server to your account, please contact DreamHost support for more info.

Widgets

Be suspicious of all widgets (or sidebar content) that will force the user to poll other DNS servers. This may delay the loading of the site.

Also, check if your theme is using custom widgets to draw recent comments of posts. If this is not handled correctly, it will poll the database every time which increases your site's load considerably.

If you're using a lot of widgets, a good option is to use a Widget Cache plugin (in addition to standard caching) to reduce the processing time for their output.

XML-RPC

WordPress uses the xmlrpc.php file for remote administration purposes such as posting via third party applications. However, this file can be a target for attackers.

To protect your site, DreamHost has implemented rate-limiting on this file. You can disable xmlrpc.php although some plugins which depend on it (like Jetpack) may no longer work if you do.

Other common reasons for poor performance

There are many more reasons a site could run slower than expected. View the following article for further information on how to troubleshoot other issues such as CSS, JavaScript, and internet issues.

Viewing your site's access.log file

Every DreamHost website stores access.log information about the site. These logs can become very large and difficult to read, so there are a few commands you can run to quickly tell which site is getting the most traffic. View the following article for further details:

Missing files

Sometimes, due to upgrades or some poorly coded pre-packaged themes, your WordPress install might have some missing files. Missing files make the server expend a little extra effort and can drive up load considerably on a popular site. One of the most common missing files is the favicon (favicon.ico). If you've recently used the One-Click Installer, a favicon should be generated for you — but it never hurts to make sure one exists in the main directory for your site.

Adding a favicon if one doesn't already exist is easy. It does require SSH access however. In the root directory of your site (i.e. /home/username/example.com/), type:

[server]$ touch favicon.ico

This command creates a blank favicon.ico file. But a blank icon is far better than one that is missing.

To check for any other missing files, you can run your site through Pingdom Tools. A single pass through their site will point out any missing files that could be causing your site to load slowly. Just look for filenames in red and then either replace them or remove references to them in your themes or posts.

See also

Internal links

External links

Did this article answer your questions?

Article last updated .