Last active
January 26, 2021 15:46
-
-
Save Fixmysite/0de66ef50e4e887ffaddfdd4656a15f8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| /** Disable All WooCommerce Styles and Scripts Except Shop Pages*/ | |
| add_action( 'wp_enqueue_scripts', 'fixmysite_disable_woocommerce_loading_css_js' ); | |
| function fixmysite_disable_woocommerce_loading_css_js() { | |
| if( function_exists( 'is_woocommerce' ) ){ | |
| // Check if it's any of WooCommerce page | |
| if(! is_woocommerce() && ! is_cart() && ! is_checkout() ) { | |
| ## Dequeue WooCommerce styles | |
| wp_dequeue_style('woocommerce-layout'); | |
| wp_dequeue_style('woocommerce-general'); | |
| wp_dequeue_style('woocommerce-smallscreen'); | |
| ## Dequeue WooCommerce scripts | |
| wp_dequeue_script('woocommerce'); | |
| wp_dequeue_script('wc-add-to-cart'); | |
| wp_deregister_script( 'js-cookie' ); | |
| wp_dequeue_script( 'js-cookie' ); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment