Performance
How to Audit WordPress Plugins, and When Custom Code Should Replace One
The number of plugins matters less than what each one costs. A step-by-step audit with WP-CLI and Query Monitor covering maintenance, queries, autoloaded options, scheduled tasks and assets, and when a small custom plugin is the better answer.

On this page
"How many plugins is too many?" is one of the most common WordPress questions, and it has no useful answer. A site with forty well-maintained, lightweight plugins can be faster and safer than a site with eight, if one of those eight loads a large script on every page, stores a megabyte of settings that load on every request, and has not been updated in three years.
The questions that matter are what each plugin does, who maintains it, and what it costs the site: on every request, in the database, in security exposure and in maintenance. This article is a practical audit for answering them, using WP-CLI and Query Monitor. It also covers the cases where replacing a plugin with a small piece of custom code is the better answer, and the cases where it is not. It assumes you can work on a staging copy of the site and have command-line access.
What actually makes a plugin expensive
- Code that runs on every request, whether or not the page needs it.
- Database queries, especially repeated or slow ones.
- Autoloaded options: settings WordPress loads from the database on every single request.
- External HTTP calls made while the page is being generated, for licence checks, feeds or APIs.
- Front-end assets: scripts and styles added to every page, including pages that do not use the feature.
- Scheduled tasks that run often or never finish.
- Maintenance risk: a plugin that is no longer updated stops receiving security fixes.
- Overlap: two or three plugins doing parts of the same job, each with its own settings and assets.
The audit below checks each of these in turn.
Step 1: Make an inventory
Start with the facts WP-CLI can give you:
wp plugin list --fields=name,status,version,update,auto_update
wp plugin list --update=available
Then add what no tool knows: why each plugin is installed, who asked for it, and what would break without it. A shared spreadsheet is enough:
| Plugin | Purpose on this site | Used on | Owner | Overlaps with | Decision |
|---|---|---|---|---|---|
| Example forms plugin | Contact and quote forms | 3 pages | Marketing | — | Keep |
| Example slider plugin | Homepage slider (removed in redesign) | Nowhere | — | Page builder | Remove |
| Example snippets plugin | 4 small code snippets | Site-wide | Developer | — | Move to custom plugin |
Inactive plugins belong on the list too. They do not run, but their files are still on the server and still need updating or deleting.
Step 2: Check maintenance and security
For each plugin, check the WordPress.org page or the vendor's site:
- When was it last updated, and is it tested with recent versions of WordPress? The plugin directory shows a warning when a plugin "hasn't been tested with the latest 3 major releases of WordPress", and a notice when a plugin has been closed and is no longer available for download (WordPress: plugin alerts and warnings). A closed plugin may have been closed for a security issue, so treat it as urgent.
- Are there known vulnerabilities in the installed version? Public WordPress vulnerability databases list them by plugin and version.
- Is a commercial licence current? Premium plugins usually stop receiving updates when the licence lapses.
A plugin that is unmaintained should be replaced or removed even if it works today.
Step 3: Measure what each plugin costs
Do this on a staging copy, logged in as an administrator.
Requests, queries and hooks
Query Monitor shows, for each page load, the database queries grouped by the plugin or theme that made them, duplicate and slow queries, the hooks that ran, and every HTTP API call made while generating the page, with its time and the component responsible. Load the homepage, a typical content page, a page with a form and, if there is one, the shop or checkout, and note which plugins appear at the top of each list.
Pay particular attention to HTTP calls during page generation. A plugin that contacts an external server while building the page adds that server's response time to your page, and can make the site slow or broken when that server is.
Autoloaded options
Options marked to autoload are fetched from the database on every request. Over the years, plugins accumulate large ones, and deactivated plugins often leave theirs behind.
# Total size of autoloaded options
wp option list --autoload=on --format=total_bytes
# The 20 largest; the option name usually reveals which plugin owns each one
wp option list --autoload=on --fields=option_name,size_bytes \
| sort -n -k 2 | tail -n 20
Since WordPress 6.6, options larger than 150 KB are no longer autoloaded by default, and Site Health reports a critical issue when the total of autoloaded options exceeds 800 KB (WordPress 6.6 developer note). Older sites can still carry large autoloaded options that were created before that change.
Scheduled tasks
wp cron event list --fields=hook,next_run_relative,recurrence
Look for events that run every minute, events belonging to plugins that are no longer installed, and events that are overdue, which can mean WordPress's scheduler is not running reliably on the site.
Front-end assets
In the browser's developer tools, check which scripts and styles each plugin adds to pages that do not use it. A gallery plugin's script on every page, or a form plugin's styles on pages without forms, are common findings. Many plugins have a setting to load assets only where they are needed. For more on finding what slows pages down, see how to improve website speed.
Step 4: Decide, plugin by plugin
Every plugin ends the audit with one of five decisions:
| Decision | When |
|---|---|
| Keep | It is maintained, needed, and its cost is reasonable |
| Reconfigure | It is needed, but loads assets or runs work where it should not |
| Replace with a better plugin | The feature is needed but this plugin is unmaintained or heavy |
| Replace with custom code | The feature is small and specific to this site |
| Remove | Nobody can say what it is for, or the feature is no longer used |
When custom code is the better answer
Custom code makes sense when the job is small, specific and stable, and a general-purpose plugin brings far more than the site needs. Typical examples:
- registering a custom post type or taxonomy;
- a handful of code snippets kept in a "snippets" plugin;
- a single shortcode or a small block;
- a redirect, a header or a small change to WordPress's default behaviour;
- one specific integration with a system the business uses.
For example, a site that installed a large plugin only to create a "Case studies" section can replace it with a few lines in a must-use plugin:
<?php
/**
* Plugin Name: Site: case studies
* Description: Registers the case study content type. A must-use plugin,
* so it cannot be deactivated by accident.
*/
add_action('init', function (): void {
register_post_type('case_study', [
'label' => 'Case studies',
'public' => true,
'has_archive' => true,
'rewrite' => ['slug' => 'case-studies'],
'show_in_rest' => true, // enables the block editor
'supports' => ['title', 'editor', 'thumbnail', 'excerpt'],
'menu_icon' => 'dashicons-portfolio',
]);
});
Must-use plugins are PHP files in wp-content/mu-plugins. They load automatically, before normal plugins, and cannot be deactivated from the admin; only files directly in that folder are loaded, not files in subfolders (WordPress: must-use plugins). That makes them a good home for code the site cannot work without. Two practical points: keep the post type name and slug identical to the ones the old plugin used, so existing content and addresses keep working, and refresh permalinks once afterwards (saving the Permalinks settings page is enough).
Custom code is not free. It is code someone has to understand, keep compatible with new WordPress and PHP versions, and fix when it breaks. Keep it small, keep it in version control, and document what each piece does.
When to keep the plugin
Do not replace a well-maintained plugin with custom code for features that are large, security-sensitive or change with outside rules: e-commerce and payments, membership and access control, multilingual content, backups, and form handling with spam protection. A mature plugin used by many sites gets security fixes and compatibility updates that a small custom version would not. The best outcome of an audit is often fewer plugins, each of them good, rather than no plugins at all.
Removing plugins safely
-
Work on staging first, with a fresh backup of files and database.
-
Find content that depends on the plugin. A removed shortcode prints as raw text in the page. Search for it before removing the plugin:
wp db search '[old_gallery' -
Deactivate, test, then delete. Check the pages listed in your inventory, forms, and anything logged-in users do.
-
Clean up what it leaves behind. Some plugins remove their options and tables on uninstall, many do not. Check the options and cron events found in step 3 again.
-
Watch after release: the PHP error log, 404 errors and form submissions for the following days.
Make it routine
An audit once is useful; a short review every few months keeps the site from drifting back. Keep the inventory up to date, add a line whenever a plugin is installed (with its purpose and owner), and repeat the measurements in step 3 after major changes. The wider routine of updates, backups and access control is covered in the website maintenance and security checklist.
If the audit raises the bigger question of whether WordPress is still the right platform for what the site has become, WordPress vs. custom website development is a fair comparison of the two.
Help with a WordPress audit
Digital Solutions does WordPress development as engineering work: custom plugins and themes, troubleshooting, and replacing fragile plugin combinations with code that fits the site. The WordPress custom systems case study shows the kind of work involved, and WordPress performance optimisation covers sites where speed is the main concern. If your site has grown into a collection of plugins nobody fully understands, describe it and we can start with the inventory.


