Disable wp_enqueue_styles action for specific page

I have an specific page on my website where I can’t have any stylesheets being enqueued, so I need to unenqueue all stylessheets loaded there. Problem is I don’t know their IDs, because they can come from either several different themes or other plugins.

What I’ve tried to do is remove the wp_enqueue_styles action, but without luck.

Here’s what I’ve tried:

add_action( 'init', 'remove_enqueue_action', 99);
function remove_enqueue_action() {
    remove_action( 'wp_enqueue_styles','' );
}

Any help is appreciated.

3 Answers
3

Check the $wp_styles global to get the stylesheet IDs.

global $wp_styles;
var_dump($wp_styles);

Look for the handle key. Or…

var_dump(array_keys($wp_styles->registered));

That should give you what you need to dequeue them.

Leave a Comment