WordPress is a powerful content management thanks to huge number of plugins. However, installing too many plugins on your site can easily take a toll on the page loading speed. Especially, heavy resource utilizing plugins like WooCommerce will slow down your website considerably. In most situations, you may really need a plugin on certain posts and not on other content on your site. If you are looking for a solution to disable plugins on specific posts, here is a tutorial for you.
Related: Fix briefly unavailable for scheduled maintenance error in WordPress.
Why to Control Plugins Loading?
There are many situations you need a plugin to work only on few pages/posts on your site. However, the plugin will load CSS and JS files throughout the site slowing down other posts where there is no need. Here are some of the good examples:
- Contact form plugins like Contact Form 7 loads CSS and JS files throughout your site. However, you may be using few contact forms only on pages and not on posts.
- Page builder plugins like Elementor and WPBakery are needed only on pages (unless you use them on posts).
- Ecommerce plugins like WooCommerce is needed only on shop and product pages, especially if you are not using mini cart in the menu.
- Coupon plugins like WP Coupons create a custom post type “coupons”.
- Review plugins like WP Review Pro is needed only on the pages with review.
- Glossary plugins like CM Tooltip Glossary create a custom post type “glossary”.
The list will go on for any special purpose plugin that you install on your site. Unfortunately, none of these plugins offer option in the plugin’s settings to control loading of CSS and JS only on related pages. In all the above cases, you can control plugins loading on specific posts where they are needed and disable them on other posts.
Disable Plugins on Specific Posts
In our earlier article, we have explained how to remove unused CSS and JS with the use of Asset Cleanup plugin. However, the free version of this plugin only helps you to disable files and not the the complete plugin. In order to disable plugin on specific post type, you need to purchase the premium version which will cost $47 for single site license.
There is also another premium plugin called Gonzales which you have to purchase from third-party developer website. This will cost you $29 for single site license. Fortunately, there is a free plugin available in WordPress repository for control the loading behavior of installed plugins on your site.
Install Plugin Organizer
Go to your WordPress admin panel and navigate to “Plugins > Add New” section. Type plugin organizer to find Plugin Organizer plugin.
After finding the plugin, install and activate on your site to see it in action.
What Can You Do With Plugin Organizer?
You can do the followings with Plugin Organizer plugin:
- Rearrange the order of plugin loading.
- Disable plugins globally and enable only on particular posts.
- Selectively disable the plugins on particular post types.
- Create groups to combine plugins and use for offloading and reordering.
Our focus in this article is to selectively control plugins loading on specific posts. Remember, disabling or reordering plugins on your site may cause unforeseen results. The plugin will show you warning on this and make sure to test your site thoroughly with your caching plugin.
Enabling Plugin Settings
After installing the plugin, go to “Plugin Optimizer > Settings” menu to enable or disable the required options. in order to disable plugins on selected post types, you have to enable the following options:
- Selective plugin loading – this is the option that allows you to disable plugins site wide. After enabling this option, go to “Manage MU plugin file” tab and click on the “Copy” button. This will copy the MU plugin to your site’s “/wp-content/mu-plugins” folder. This is a mandatory step for the plugin to work.
- Selective mobile plugin loading – turn on this option when you want to disable certain plugins only on mobile devices. This is useful when you have separate mobile themes for your site. By default, leave this option as turned off. If you have enabled then check and add the user agents under “Mobile User Agents” tab.
- Selective admin plugin loading – enable this option for controlling plugins loading on the admin panel.
- Disable plugins by role – disable or enable plugins based on user roles available on your site.
- Disable debug message – the plugin will show debug messages about the enabled and disabled plugins on the browser frontend when you turn this option on.
In addition, you can choose debugging roles, role support and custom post type support and save your changes.
Disable Plugins Globally on Your Site
If you want to disable any plugin on your site temporarily, go to “Plugin > Organizer > Global Plugins”. Here you can view and disable the plugins on your site.
Though this is not required in normal scenarios, you can use this feature for troubleshooting purposes. You can edit individual post and enable the plugins from the editor. When you are in the editor, select “Override Post Type settings” checkbox. This will show similar controls like you see on the global settings page. Click on any plugin to disable it on the post for the selected role and publish your post. In this manner, you can test the behavior of any plugin only on certain post or page on your site without affecting the other content.
Disable Plugins on Search Result Pages
Go to “Plugin Organizer > Search Plugins” and disable unnecessary plugins that you do not want to load on the search result pages.
Again, this is not useful in normal scenario unless users primarily rely on the search function on your site.
Disable Plugins on Specific Posts
This is the main feature you will be interested with the Plugin Organizer. Go to “Plugin Organizer > Post Type Plugins” and choose the post type. For example, you may want to offload Akismet Anti-Spam plugin on pages which generally do not have comments. In this case, choose “page” as post type and click on the Akismet Anti-Spam plugin.
You can choose the role as “Not Logged In”, so that the deselected plugin will not load for all not logged in users. Note that after deselecting, the plugin color will change to red indicating it is not active. Click on save button to disable the selected plugins on the selected post type. As mentioned, you can go to the post or page editor and change global settings to load plugins only on that post or page.
Plugin Organizer is a useful plugin for controlling plugins loading on specific posts or pages in WordPress site. You can also globally disable the plugin and enable only on specific posts. It is also possible to control the resources loading on custom post types. You can use this plugin for increasing page loading speed by eliminating warnings like remove unused JS/CSS and remove render blocking JS/CSS.
So, if I want to disable a plugin on say, the home page, but not on the other pages or blog posts, then I’d need to do the following:
(1) disable the plugin globally and then
(2) go to all the other pages (except the home page) and blog posts and enable the plugin?
If so, this will get quite time consuming for my site since I’d have so many plugins that I’d want to enable/disable on different pages and posts.