/** * Remove Woo Styles and Scripts from non-Woo Pages */ add_action( 'template_redirect', 'bt_remove_woocommerce_styles_scripts', 999 ); function bt_remove_woocommerce_styles_scripts() { // Skip Woo Pages if ( is_woocommerce() || is_cart() || is_checkout() || is_account_page() ) { return; } // Otherwise... remove_action('wp_enqueue_scripts', [WC_Frontend_Scripts::class, 'load_scripts']); remove_action('wp_print_scripts', [WC_Frontend_Scripts::class, 'localize_printed_scripts'], 5); remove_action('wp_print_footer_scripts', [WC_Frontend_Scripts::class, 'localize_printed_scripts'], 5); }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter