-
-
Save niladam/7928a48417667721bbd4 to your computer and use it in GitHub Desktop.
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
<?php | |
// Make sure you only use opening / closing tags if needed!!! | |
// Late priority so WC can't jump back in and re-enqueue them | |
add_action( 'wp_enqueue_scripts', 'woocommerce_de_script', 100 ); | |
// Removes WooCommerce Scripts on non shop/product/cart/checkout pages | |
function woocommerce_de_script() { | |
if ( function_exists( 'is_woocommerce' ) ) { | |
if ( !is_shop() && !is_cart() && !is_checkout() && !is_account_page() && !is_page_template( 'custom-template.php' ) { | |
// if we're not on a Woocommerce page, dequeue all of these scripts | |
wp_dequeue_script('wc-add-to-cart'); | |
wp_dequeue_script('jquery-blockui'); | |
wp_dequeue_script('jquery-placeholder'); | |
wp_dequeue_script('woocommerce'); | |
wp_dequeue_script('jquery-cookie'); | |
wp_dequeue_script('wc-cart-fragments'); | |
} | |
} | |
} | |
// Make sure you only use opening / closing tags if needed!!! | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment