WordPress at a glance

Do plugins slow down the WordPress?

This short article is my attempt to answer the common question — what is better: install a plugin to add desired functionality or add custom code in functions.php? And it destroys the claims of laymen that plugins are evil by themselves because they slows down WordPress. Below I will show you how one and several plugins affect WordPress loading speed.

Once I was asked the following question:

I know that it's better to avoid many plugins on your WordPress website because they slow down it. I have a question: I use a plugin to create tables on pages, and after creating them, I deactivate the plugin — tables were created and they work now.

Do deactivated plugins affect the speed of the website? Please explain in detail. Thank you!

Let's find out...

A fact: an activated plugin does not overload WordPress!

The statement that "a large number of WordPress plugins slow down the website" is quite controversial and, in fact, is wrong! It totally depends on plugins, their functionality and quality.

In general, activated plugins by themselves do not affect the speed of the website and the front-end in particular. But inactive plugins never affect the speed: they just take up space on the disk and slightly affect the speed of loading of Plugins page in the dashboard as the plugin information is read from the main plugins files. Nothing else!

To understand why this is the case, let's take a look at how plugins are loaded in WordPress.

The principle of plugins loading in WordPress

When you activate a plugin, WordPress writes the path to its main file in the active_plugins option. Next, when you load any page (admin, front, Cron, AJAX, REST), WordPress gets a list of all active plugins from the active_plugins option that contains an array of names of the main plugin files. After receiving the option, WP simply runs (includes) the main file of each plugin. The wp_get_active_and_valid_plugins() function returns a list of active plugins. The code of including plugins in php is in the wp-settings.php file and looks like:

// Load active plugins.
foreach ( wp_get_active_and_valid_plugins() as $plugin ) {
	wp_register_plugin_realpath( $plugin );
	include_once( $plugin );
}
unset( $plugin );

And this is the option where active plugins are stored:

$active_plugins = get_option( 'active_plugins' );

/* Getting in $active_plugins
Array
(
	[0] => 404-error-monitor/index.php
	[1] => backupwordpress/backupwordpress.php
	[2] => democracy-poll/democracy.php
	[3] => disable-emojis/disable-emojis.php
)
*/

This demonstrates that a plugin with empty code, that does nothing at all, does not affect the speed of the website at all. Since the active_plugins option is obtained anyway, and PHP files are included very quickly (this is the standard procedure in PHP).

And there are no inactive plugins in the list, which means they do not affect the speed of the website at all!

33 plugins...

Let's imagine that we have 32 plugins, each of which consists of a couple of lines of code and makes minor changes to the work of WP. And there is another plugin that consists of 1000 lines of code and makes changes several times more than those 32 plug-ins combined: it disables filters, includes its own, makes queries to the database, updates/checks something, adds functionality to the website and displays some blocks in the admin and front and does something else...

So the last one will overload the system much more than those 32 together! For this example, we can compare a heavyweight "WooCommerce" and small plugins like "Disable Emojis", "Disable File Editor", "Cyr to Lat".

So the statement "the more plugins we have, the worse WordPress works" is false. Not quantity, but complexity matters!

When do plugins affect the speed of the website?

The impact on the speed occurs in the code of the plugin, so it completely depends on the functionality of the plugin and the quality of its code.

Also, the impact occurs when WordPress checks for a new version of the plugin at the time of the scheduled task (cron): inactive and active plugins are checked. But it happens only in the dashboard and not all the time (only when cron job is scheduled).

By the way, WordPress makes only one request to its API and receives data for all installed plugins from the repository at once. And premium plugins (if they have auto-update) usually make one request for a plugin!

How do I know which plugin slows down the system the most?

If you have problems and you think it's a fault of the plugin then you can:

  • Use the good old method of disabling plugins one by one and see how it impacts website speed.

  • Install the well-known "Query Monitor" plugin and see what statistics it shows during page load. If it shows excessive amount of load, then you can see what plugins, functions, hooks or files created it. So you can understand which plugin slows down your website...

  • Install the "P3 (Plugin Performance Profiler)" plugin and maybe it will show you the bottleneck.
No comments
    Log In