How to disable a Plugin’s Styles

Disable Plugin StylesheetsAt times you might need to disable a plugin’s styles, this might be for speed optimisation purposes for example. In this case you might be aiming to minimise requests for scripts by combining 2 or more stylesheets into one file. Another optimisation would be to use conditionals to only load the plugin script on pages which require it. Another reason why you would want to disable styles is to use your own style for that plugin, instead of overriding the styles in your default stylesheet, which not always works well due to the fact that some plugins have styles that are not that easy to override.

In any case, to disable a stylesheet you can look into your plugin’s code and see what handle is being used. You need to look for a line that looks like this:

Then include the following code in your functions.php:

This will disable loading of that stylesheet.

If you want to only enable a stylesheet on a particular page where the plugin is used, you can use something like this:

That will only load your contact form plugin style where it is used, i.e. the Contact page.

One word of warning before you dive into your functions.php file however, usually plugins will give you some options for customising their appearance and even setting custom style sheet from within the WordPress dashboard itself, so it is usually easier to go down that route if it is available. You can also try to override styles in your default stylesheet using the ‘!important’ option in your CSS and playing around with specificity.

Further Reading

Another interesting read on this topic is Justin Tadlock’s review on disabling scripts and styles in WordPress.

About Jean Galea

Jean Galea is a WordPress developer, entrepreneur and padel player. He is the founder of WP Mayor, the plugins WP RSS Aggregator and EDD Bookings, as well as the Mastermind.fm podcast. His personal blog can be found at jeangalea.com.

Related Articles

  • Best Plugin to Display Syntax-Highlighted code in WP

    Today we take a look at plugins used for syntax highlighting within blog posts. Check out the best plugin for syntax highlighting.

  • Recommended Formatting for Plugin Headers

    As an aid to plugin developers, we will be frequently posting code snippets or tutorials about best practices. Today we will be dealing with the simplest and most essential part…

  • WPTouch Pro Mobile SIte

    WPtouch Pro is one of the most versatile WordPress plugins for converting a website to a mobile site. Customized formatting to selective menu options to integrating your ad service, WPtouch…

Leave a Reply