Remove plugin JS or CSS – WordPress methods

Remove plugin JS or CSS – WordPress methods

Making a WordPress site without using any plugin is near to impossible and unimaginable, because WordPress plugins are great ready-made code libraries which can built features for you with just single click. WordPress plugins are exists for extra functionality.

There are bunch of plugins are available almost for any of the web development needs some of them are available freely and some of them are premium where you have to buy plugin if you like to use. Many WordPress plugins having their own styles and scripts in form of CSS and JS. These plugins inject javascripts and stylesheets into the pages where the plugin features used.

If you are not planning to add custom styling for pages/elements created by plugin then there is no problem. Also the plugin is specially designed for back-end like WP Show Stats to see various stats about how different WP elements used on your site. But if you already applied styles to other pages and your own styles conflict with plugin styles or javascripts then you will need to identify that and resolve conflicts between them. Here you will sometime need to remove javascripts and specially stylesheets added by plugin.

If you like to find any stylesheets or javascripts added to your page then you can identify from your webpage source (right click on any page and click on View Source). There you can see stylesheets and javascripts added by plugins you installed in footer area or in header area.

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');

It is very tedious task when you have additional styles or scripts loaded from any plugin and that messing up the content on your site. Sometimes even deregistering them is not enough as well. If methods shown above to remove plugin js or css then feel free to ask for help using comments and I will try best to help you in resolving issues.

More reference:

https://codex.wordpress.org/Function_Reference/remove_action

https://codex.wordpress.org/Function_Reference/wp_deregister_script

https://codex.wordpress.org/Function_Reference/wp_deregister_style

Speak Your Mind

 

I’ve worked with Ashish for a couple years now and have enjoyed consistently great results. He’s easy to work with, attentive and reliable. He brings a diverse set of web development skills to the table and has excelled at every project we’ve engaged him on. I highly recommend him.

Ash is awesome to work with, he makes sure he understands the project and delivers beyond expected work with precision on time delivery. Ash and his team is great to work with and I highly recommend them. Working with Ash you dont have to worry about the final product cause they also do QA before its delivered to your server. Great JOB Ash being great working with you.

Ashish is a good resource for our team. We have been working with him for the past 5 years and delivers work on time. He’s always ready to go an extra mile to please our clients. Hope to continue working together!

Ashish is a professional who meets the agreed schedule. He is always well disposed to help. Is a very kind person. He is a professional with excellent technical level.

I have been looking for a great developer for a while now, and I was very happy to find Ashish. He does great work, and meets deadlines on a consistent basis. He requires very little oversight, as everything is typically done 100% correct the first time. I absolutely recommend Ashish as a developer.

Ashish and his team did a wonderful job on our company website. The project was reasonably priced, he finished it on time, and it is just as functional as it is beautiful. Our website is an essential part of our business, and we get compliments on it all the time. I would highly recommend Ashish for website development.

Ashish and his team were creative, responsive, and worked within our budget to create a fantastic looking website that has all the functionality we wanted. He is so talented, we feel lucky to have found him. I HIGHLY recommend him to anyone looking for a website developer.

Ashish does all my web stuff. Fast and does a brilliant job. Thanks Ashish, great work.

Ashish is an amazing programmer. He is quick to help and very knowledgeable. I feel confident taking almost any issue to him and he is able to work through it. Very friendly and professional.

Ashish is very thorough and we really like working with him. He will be a great asset to any organization.

Free and best WP plugin to analyze your site with the help of charts.
WP Show Stats plugin

+91 9033402074

Freelancer Coder
238, Back Bone Shopping Center,
Chandresh Nagar Main Road,
Mayani Chowk, Rajkot - 360004,
Gujarat, India