Remove Unwanted WordPress Plugins' JS or CSS

WordPress plugins can make a WordPress site more powerful and easier to use. There are over 50,000 different plugin options, with something for everyone. Whether you're looking to make your site mobile-friendly or create a membership option, there's a plugin for you in the library of over 50,000.

You can find a WordPress plugin for any function you need. Some of them are free, but many of the premium plugins come with their own scripts and stylesheet to add functionality.

If you do not plan to modify the structure of any page created by a plugin, there is no problem. However, if you have applied styles to other pages and your own styles conflict with plugin styles, then you will need to identify this and resolve conflicts between the two. You might need to remove any additional javascripts and stylesheets added by the plugin.

If you want to find javascript or stylesheet which was added to your site, find the source of your web page and see if there are scripts that were added by plugins or code in the footer or header.

Ways to remove plugin js or css

1. De-register – Remove plugin js or CSS

Remove plugin js or css using wp_deregister_script() and wp_deregister_style() methods. The option will work most of times.

function remove_unwanted_scripts_styles() {
// deregister styles
wp_deregister_style('unwanted_css'); // stylesheet name

// deregister scripts
wp_deregister_script('unwanted_js'); //javascript name 
}   
add_action('wp_footer', 'remove_unwanted_scripts_styles');

2. Remove plugin js or css by removing action

If deregister methods not working for you then you can try by removing action. Some plugin are not built with recommended way as styles and js are not included with wp_enqueue methods. Then you can use remove_action() method.

remove_action('wp_head', 'unwanted_js');

Plugins can affect the code on your site and cause many problems. It can be difficult to get WordPress plugins to work correctly, so please feel free to reach out if you are having any issues with the website.

Comments

Popular posts from this blog

Latest free website directory list 2022.

Some best utility plugins for WordPress website

How to Write a Blog Post That Drives Traffic and Sales