Unable to wp_dequeue_script prettyPhoto
-
Hi,
I am using below code to de-register unneeded woocommerce elements on non-woocommerce pages. All working well apart of prettyPhoto that despite below is still loaded on non-woo pages. Any advise?// WooCommerce - Remove scripts and styles on non-shop pages add_action( 'wp_enqueue_scripts', 'disable_woocommerce_loading_css_js' ); function disable_woocommerce_loading_css_js() { // Remove the generator tag remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) ); // 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'); wp_dequeue_style('woocommerce_prettyPhoto_css'); ## Dequeue WooCommerce scripts wp_dequeue_script('wc-cart-fragments'); wp_dequeue_script('woocommerce'); wp_dequeue_script('wc-add-to-cart'); wp_deregister_script( 'prettyPhoto-init' ); wp_dequeue_script( 'prettyPhoto-init' ); wp_deregister_script( 'prettyPhoto' ); wp_dequeue_script( 'prettyPhoto' ); wp_deregister_script( 'js-cookie' ); wp_dequeue_script( 'js-cookie' ); } } }
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
- The topic ‘Unable to wp_dequeue_script prettyPhoto’ is closed to new replies.