Published on 07/29/2022
Published by amit
How to dequeue third-party plugin enqueued styles and scripts in WordPress
In case you need to remove or dequeue a stylesheet or Javascript file enqueued by some third-party plugin in WordPress you can use the following code sample
1 2 3 4 5 |
add_action( 'wp_enqueue_scripts', 'aws_dequeue_style',100 ); function aws_dequeue_style() { wp_dequeue_style( 'ubermenu-font-awesome-all' ); wp_dequeue_style( 'ubermenu-montserrat' ); } |
Few point to note
- If you don’t know the handle used to register the style or script view the source code and find the line where CSS is included like it is shown in the example below
1<link rel='stylesheet' id='dashicons-css' href='/wp-includes/css/dashicons.min.css?ver=6.0.1' type='text/css' media='all' />
In this, the “id” attribute has the handler without the “-css” or “-js” postfix. So, in the example above the handler is “dashicons“.