Remove plugin JS or CSS – WordPress methods

Remove plugin JS or CSS – WordPress methods

Posted on 6 Aug, 2015 by Ajani Ashish | No comment

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:

Related Post

What is vCard and how to generate vCard from WordPress

Posted on 13 Aug, 2015 by Ajani Ashish | No comment I 4311 views

This article is about how can we generate vCard from WordPress. Probably, you may have seen a vCard attached to e-mail note which someone has sent you. It is a file format standard for business cards in electronic form. What...

Read More

Determine technologies a website built on

Posted on 11 Apr, 2015 by Ajani Ashish | No comment I 1835 views

Determine technologies a website built on Often we go through a well functioning or nice looking website and wonder that what technologies might be used to create these great sites. So what are the options or techniques...

Read More
No Comments (0)

Speak Your Mind

sixteen − = seven