Woocommerce Remove Inline Styles Added After 9.9 Update

With Woocommerce’s 9.9 update, they unleashed a hurricane of inline CSS that is now likely drowning millions of websites with unnecessary, bloated code.

Take a look at your site’s code, if you’ve done the update, for these lines of code:


<style id='woocommerce-product-button-style-inline-css' type='text/css'>.wp-block-button.wc-block-components-product-button{...}</style>
<style id='woocommerce-product-collection-style-inline-css' type='text/css'>.wp-block-woocommerce-product-collection .wc-block-components-product-stock-indicator{...}</style>
<style id='woocommerce-product-filters-style-inline-css' type='text/css'>:where(.wc-block-product-filters){...}</style>
<style id='woocommerce-product-filter-removable-chips-style-inline-css' type='text/css'>.wc-block-product-filter-removable-chips.is-vertical ...</style>

Woo is adding a whopping 9 stylesheets!

To remove all of this torrential gobbledygook, just add the following to your functions.php file.


// remove Woocommerce inline styles added in 9.9
add_action( 'wp_print_styles', function(){
wp_styles()->add_data( 'woocommerce-product-button-style', 'after', '' );
wp_styles()->add_data( 'woocommerce-product-collection-style', 'after', '' );
wp_styles()->add_data( 'woocommerce-product-filters-style', 'after', '' );
wp_styles()->add_data( 'woocommerce-product-filter-price-slider-style', 'after', '' );
wp_styles()->add_data( 'woocommerce-product-filter-removable-chips-style', 'after', '' );
wp_styles()->add_data( 'woocommerce-product-filter-checkbox-list-style', 'after', '' );
wp_styles()->add_data( 'woocommerce-product-filter-chips-style', 'after', '' );
wp_styles()->add_data( 'woocommerce-product-gallery-style', 'after', '' );
wp_styles()->add_data( 'woocommerce-product-template-style', 'after', '' );
});

Up Next: How to Delete a WordPress Site and All of Its Users