WordPress at a glance
Home WordPress Codex

Do plugins slow down WordPress?

This short article is my attempt to answer the common question — what is better: install the plugin 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.

The next question I was asked once:

I know that it's better to avoid many plugins on your WordPress site 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 site" 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 site 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 includes the main file of each plugin in PHP. The wp_get_active_and_valid_plugins() function return the list of active plugins. The code of including plugins in php is in the wp-settings.php file and looks like this:

// 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
	[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 site at all. Since the active_plugins option is obtained anyway, and the file that connects in PHP includes very quickly (this is the standard procedure in PHP).

There are no inactive plugins in the list, which means they do not affect anything 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 costs 1000 lines of code and makes changes several times more than the previous 32 plug-ins combined: it disables filters, includes its own, makes queries to the database, updates/checks something, adds functionality to the site and displays some blocks in the admin and front and does something else...

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

The statement "the more plugins, the worse WordPress loads" is false. Not quantity, but complexity matters!

When do plugins affect the speed of the site?

The impact on the speed of work 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 one plugin!

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

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

  • Use the old good method of disabling plugins one by one and see how the site behaves.

  • Install the well-known "Query Monitor" plugin and see what statistics it shows during a page loading. If it shows excessive load, then it is sure to be seen what plugin, function, hook or file creates this load. So you can understand which plugin is a subject to blame...

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