This Cyber Monday Envato Tuts+ courses will be reduced to just $3. Don't miss out.
Installing WordPress is really easy. Optimization is what takes time. Not everyone who owns or maintains a WordPress website on their own is a programmer. Many WordPress users do not even know HTML. You may buy hosting from the best hosting provider but there are few things that need to be checked for maximum performance. This tutorial is not about optimization or setting up caching plugins. Those topics have been covered in the past. Today we will learn about plugins that could help us analyze the performance of a WordPress website to understand the problem areas and see their impact on the website.
WordPress is a complex piece of software. There are lot of things going on in the background that are required to load a page. Directly installing a caching plugin will definitely speed up the site a bit, but understanding how your active theme and plugins are performing would give you more insights and enable you to fix them and make your website perform at its peek. Before we talk about the how to analyze, let's talk about what affects the performance.
Some of the factors affecting the performance of a WordPress site are:
- Errors in the theme and plugins
- Outdated code
- Number of database queries
- Lots of file requests
- Slow server
Most support tickets on WordPress.org forums are related to things not working properly. Plug-ins seem to cause the most number of issues. Unlike themes in the WordPress repository, plugins are not rigorously tested by a review team. They're looked over by one of a handful of people, but it's a cursory check for security / spam issues, not quality. Once approved, users directly upload their new plugins or updates and then users using those plugins are able to update it on their own site. If the plugin has a bug, it results in your website showing some errors or not loading at all. An often suggested solution when something like this occurs is to de-activate all your plugins and then enable them one at a time to find the problem plugin.
Before we go further, let's clear up two myths about plug-ins:
- Plug-ins that are installed but not activated do not slow down or affect your website
- How the plugins are coded affect your website and not how many plugins you have installed
Analyzing Performance of WordPress Website
To be able to analyze a WordPress website and the performance of the plugins, we are going to need a few plug-ins and some external services. For someone having a VPS or Dedicated Server and requiring more insights, you may use a paid service like New Relic that would allow you to measure the performance of posts, categories, tags and other content types and more detailed graphs. For the purpose of this article, we are only going to use the plugins and tools which are free to use.
1. Install the Tools We Would Need to Analyze Performance
- Plugin: Theme-Check
- Plugin: Log Deprecated Notices
- Plugin: Debug Bar
- Plugin: Debug Bar Cron
- Plugin: P3 (Plugin Performance Profiler)
2. Edit Your wp-config.php File
Open your wp-config.php and change the value of constant
true and below it add
/** * For developers: WordPress debugging mode. * * Change this to true to enable the display of notices during development. * It is strongly recommended that plugin and theme developers use WP_DEBUG * in their development environments. */ define('WP_DEBUG', true); define('SAVEQUERIES', true);
This would allow us to see any errors and get information about the database query performed on each page.
3. Test Your Theme for Errors
If your your theme has any errors which did not show up earlier, after defining
WP_DEBUG to true some hidden errors if any might now show up. Before we move to WordPress related errors, it's important that the theme does not have any major PHP Errors. Once all major errors are fixed, you could then test your theme based on the Theme Review guidelines set by WordPress.
If you have successfully installed the Theme Check plugin, then in the "Appearance" menu, you would find a "Theme Check" sub menu. The active theme is selected by default. If not make sure to select it and then click on the "Check It!" button. You are not required to follow every suggested recommendation, as some are simply marked as informational for you to consider, however it's important that you follow WordPress' standards in your theme as much as possible.
4. Check Website for Deprecated Calls
For best performance it's necessary to keep your WordPress core, themes & plugins updated to the latest stable version. The "Deprecated Calls" plugin helps to identity any code in our theme or the installed plugins that use any deprecated function calls in WordPress. The plugin also suggests the latest equivalent of the function making it easier for developers to update their code. To access the plugin data, under the menu "Tools" click on the "Deprecated Calls" link.
5. Use Debug Bar to Understand the Background Process
If you have the admin bar activated while visiting the front-end of your website, you should see a "Debug" link on the top. Click on it to display the debug information about that specific page of your website. This would allow you to quickly identify the number of queries performed to render a page in your website. Removing widgets, reducing the number of posts that are displayed, would help you in reducing the number of queries and load on the server. Debug Bar comes in handy also when analyzing which template in your theme is used to render a page/post and to also check the rewrite rules used.
6. Analyze Impact of Plug-Ins
To analyze impact of plug-ins on the overall website, we would use the P3 profile plugin. If you have already installed it, then under "Tools" menu, find and click on the "P3 Plugin Profiler" link. Click on the large blue "Start Scan" button and then choose the "Auto Scan" option to do the testing automatically. Now the plugin will load each page on the website and analyze how much time it takes to load WordPress and the plugins. Once the scan is complete, you would see a "View Results" button. Click on the button.
Using the data in the result you should now be able to understand and compare the impact of each plugin on the overall load times. Using advanced settings you can also change the test IP & log the last 100 visits.
Quick Tips on Improving Your Website's Performance
1. Fix Errors & Avoid Use Any Deprecated Functions
Fixing errors is the most important process of a website optimization.
2. Reduce MySQL Queries
The number of posts and other items displayed on each page of your website affects the load time. Reducing the number of posts, custom post types and widgets displayed on each page will reducing the number of queries and will have direct results in the speed of your website.
3. Reduce Number of HTTP Requests
4. Use Asynchronous Script or Content Loading Wherever Possible
Asynchronous loading of scripts such as Google Analytics, or any other script would allow the website to load first without waiting for this file. Currently the widest use of this is for large image galleries wherein only the images displayed in the top section of the website visible to the user are displayed and other images further along the page are loaded when the user scrolls the page.
5. Use Only Absolutely Necessary Plug-Ins
Deactivating unnecessary plugins can also help to speed up the website. Number of active plugins isn't an accurate measure for the affect on the speed of a website. Like I mentioned earlier, how the plugins are coded would affect the speed. WordPress is a community driven project. If you find a bug in a plugin, it's important that you to go the plug-in's page on the WordPress repository and mark that it does not work, and file a bug report in the forum. This helps other users become aware of any issues without having to install and check themselves.
6. Use a Caching Plugin
Once you have fixed all errors and optimized your website manually, the last step is to use a caching plugin like WP Super Cache or W3 Total Cache. I personally refer W3 Total Cache however it's advised that you try both and chose the one you are comfortable with. These plugins provide the option to combine multiple CSS/JS files into a single CSS/JS file and minify them to decrease their size reduce load times.
If there are any tools or plugins that you personally use to analyze your WordPress website's performance then please share with us in the comments. Always remember to fix any errors in your theme before using any caching plugin. Working in steps would allow you to solve errors earlier in the development of a website.