function woo_scripts_cleaner() { remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) ); if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) { $woo_styles = [ 'woocommerce_frontend_styles', 'woocommerce-general', 'woocommerce-layout', 'woocommerce-smallscreen', 'woocommerce_fancybox_styles', 'woocommerce_chosen_styles', 'woocommerce_prettyPhoto_css', 'select2' ]; $woo_scripts = [ 'wc-add-payment-method', 'wc-lost-password', 'wc_price_slider', 'wc-single-product', 'wc-add-to-cart', 'wc-cart-fragments', 'wc-credit-card-form', 'wc-checkout', 'wc-add-to-cart-variation', 'wc-single-product', 'wc-cart', 'wc-chosen', 'woocommerce', 'prettyPhoto', 'prettyPhoto-init', 'jquery-blockui', 'jquery-placeholder', 'jquery-payment', 'jqueryui', 'fancybox', 'wcqi-js', ]; // Dequeue Styles foreach ( $woo_styles as $style ) { wp_dequeue_style( $style ); } // Dequeue scripts foreach ( $woo_scripts as $script ) { wp_dequeue_script( $script ); } } } add_action( 'wp_enqueue_scripts', 'woo_scripts_cleaner', 99 );