I'm trying to figure out some kind of mechanism to load plugins on demand, depending on the page url, to improve performance.
My primary concern is that I have some admin-ajax.php calls that are recurring while the user is active on the page. I tried profiling these calls, and discovered that the majority of plugins loaded for the ajax call were unnecessary.
While I could use
is_admin() to identify an ajax call, I wish to leave WordPress and plugin code intact. Plus,
is_admin() does not differentiate between an ajax call and admin panel.
I've been looking into the plugin loading procedure. I only saw
'plugins_loaded' actions, no filters to tap into the loading process. I checked
wp_get_active_and_valid_plugins and it appears the only way to change plugin loading is to
update_option('active_plugins') explicitly, which is not a viable option. Other things are hard coded.
(I'd like to mention that this plugin http://wordpress.org/extend/plugins/selective-loading/ use the
update_option method, which in my opinion is only suitable in a non-ajax environment, or otherwise the option change wouldn't be atomic.)
I'm wondering if there was still some way to implement selective plugin loading?