Better filtering the option active_plugins or using a plugin like FDP to selectively deactivate WordPress plugins?
Sometimes people ask “isn’t it better to use the option_active_plugins filter in functions.php rather than using a plugin like FDP?”
Be careful when you read all those posts that suggest you filter option_active_plugins in functions.php of your child theme.
Why? Because WordPress calls the option active_plugins before loading the first standard plugin. The code of the theme runs after all the plugins have already fired. How can you disable a plugin after the same plugin is already loaded? This means those who write this kind of nonsense never tested their code. I would not trust this kind of author.
When you write a snippet on a blog post or a forum, you should first test it. If they tested the filter option_active_plugins written in functions.php, they would have seen that it doesn’t work. It can’t work, never.
First, if you want to write your custom code to disable specific plugins depending on your conditions, you need to do it in a file that is called before any standard plugin. Forget that it can work in functions.php, or even in the file of a standard plugin. You need to write in a PHP file located in wp-content/mu-plugins. This is what FDP does.
is it worth writing custom code in a mu-plugin instead of using FDP? Would it be better in terms of performance?
Some numbers will answer this last question.
In the following tables, you can see the memory usage of FDP and some popular plugins like Contact Form 7, Advanced Custom Fields, Elementor, and WooCommerce.
Freesoul Deactivate Plugins (FDP)
Contact Form 7
Advanced Custom Fields (ACF)
Elementor
WooCommerce
Well, on the frontpage FDP consumes around 9 kB of memory usage, while the other mentioned plugins consume respectively: Contact Form 7 -> around 110 kB, Advanced Custom Fields -> around 1 Mb, Elementor -> around 1.6 Mb, and WooCommerce -> 5.4 Mb.
Also, take into account that FDP doesn’t add any HTTP requests. On the contrary, most of the plugins also add HTTP requests.
Now you can answer yourself.