I’m trying to get rid of unused styles in my WP. I’m doing it like this:
// remove CSS
add_action('wp_dequeue_style', 'remove_css');
function remove_css() {
// boostrap shortcodes
wp_dequeue_style(array(
'bs_bootstrap-css',
'bs_shortcodes-css'
));
// woocommerce
wp_dequeue_style('woocommerce-layout-css');
wp_dequeue_style('woocommerce-smallscreen-css');
wp_dequeue_style('woocommerce-general-css');
}
Problem is, neither first nor the secound example works. I tried using wp_deregister_script
and setting a priority to add_action
. What can I do?
You should hook into
wp_enqueue_scripts
:Woocommerce has a filter for that, also note that the handles do not have “-css” at the end.
Code shamelessly copied from the following link 🙂