Remove WooCommerce styles and scripts

Posted by on Apr 20, 2014 in Blog, E-Commerce, Woocommerce | No Comments

This is not a tutorial, more a record of a handy bit of code. You may not want to remove all of this in a real world scenario, although you never know. More likely there will be a particular script and css that you wish to remove as I did in this tutorial on using a different lightbox with Woocommerce. You could also pop a conditional statement inside the function to remove them only on a certain page or group of pages.

<?php
/**
 * WooCommerce Extra Feature
 * --------------------------
 * Remove WooCommerce styles and scripts.
 *
 */
function woo_remove_styles() {
		
		// Styles
		wp_dequeue_style( 'woocommerce_frontend_styles' );
		wp_dequeue_style( 'woocommerce_fancybox_styles' );
		wp_dequeue_style( 'woocommerce_chosen_styles' );
		wp_dequeue_style( 'woocommerce_prettyPhoto_css' );
		
		// Scripts
		wp_dequeue_script( 'wc_price_slider' );
		wp_dequeue_script( 'wc-single-product' );
		wp_dequeue_script( 'wc-add-to-cart' );
		wp_dequeue_script( 'wc-cart-fragments' );
		wp_dequeue_script( 'wc-checkout' );
		wp_dequeue_script( 'wc-add-to-cart-variation' );
		wp_dequeue_script( 'wc-single-product' );
		wp_dequeue_script( 'wc-cart' );
		wp_dequeue_script( 'wc-chosen' );
		wp_dequeue_script( 'woocommerce' );
		wp_dequeue_script( 'prettyPhoto' );
		wp_dequeue_script( 'prettyPhoto-init' );
		wp_dequeue_script( 'jquery-blockui' );
		wp_dequeue_script( 'jquery-placeholder' );
		wp_dequeue_script( 'fancybox' );
		wp_dequeue_script( 'jqueryui' );
	
}
 
add_action( 'wp_enqueue_scripts', 'woo_remove_styles', 99 );
?>

Leave a Reply