Created
September 7, 2017 09:36
-
-
Save bewho/162c1fe863f5cf943fbbd42f991eea6a to your computer and use it in GitHub Desktop.
Stop Loading WooCommerce .js (javascript) and .css files on all WordPress Posts/Pages
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
//* http://crunchify.com/how-to-stop-loading-woocommerce-js-javascript-and-css-files-on-all-wordpress-postspages/ | |
//* Enqueue scripts and styles | |
add_action( 'wp_enqueue_scripts', 'crunchify_disable_woocommerce_loading_css_js' ); | |
function crunchify_disable_woocommerce_loading_css_js() { | |
// Check if WooCommerce plugin is active | |
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('wc-cart-fragments'); | |
wp_dequeue_script('woocommerce'); | |
wp_dequeue_script('wc-add-to-cart'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment