This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This code snippet removes JavaScript and CSS files loaded from WooCommerce if they are not necessary. | |
* | |
* Please test this on a staging copy of your website before putting this into the functions.php of your live website. | |
*/ | |
add_action( 'wp_enqueue_scripts', 'my_remove_woo_assets', 99 ); | |
function my_remove_woo_assets() { | |
if ( function_exists( 'is_woocommerce' ) ) { // Check if Woo is installed. | |
if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) { // Only run on non-Woo pages. | |
// Remove unnecessary stylesheets. |