In this article we will teach you how to remove css or styles in wordpress.
Some times we need to remove some css from our wordpress website or blog to speed up our website. Here below is a trick which you can use to remove unused css from your wordpress website.
First of all you have to find the stylesheet file which you want to remove and to find this open your webpage in google chrome and press ctrl+u to view the source code of the webpage, then find the link tag of css file and there you will see the id in the link tag and this is what you need to remove the css. Now paste the code given below in your functions.php file located at root_directory_path/wp-content/themes/your_theme/functions.php
And we have used here two wordpress core functions wp_dequeue_style and wp_deregister_style.
Here ‘wc-block-style’ is the id of the link tag which you have found in source code of webpage. You can also see the image below to find id of css.
function dequeue_my_css() {
if (is_home() == true || is_single() == true) {
wp_dequeue_style('wc-block-style');
wp_deregister_style('wc-block-style');
}
}
add_action('wp_enqueue_scripts','dequeue_my_css', 9999);
add_action( 'wp_head', 'dequeue_my_css', 9999 );
That’s it Now you have learned the trick how to remove css or styles in wordpress.
And if you want more tutorials and tricks about wordpress then visit our WordPress Page and follow us on facebook, twitter, tumblr, linkdedin and if you like this article then share this.