• Hello there,

    This Code is no more working. Is there any alternative?

    /** Disable All WooCommerce Styles and Scripts Except Shop Pages*/
    add_action( ‘wp_enqueue_scripts’, ‘dequeue_woocommerce_styles_scripts’, 99 );
    function dequeue_woocommerce_styles_scripts() {
    if ( function_exists( ‘is_woocommerce’ ) ) {
    if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) {
    # Styles
    wp_dequeue_style( ‘woocommerce-general’ );
    wp_dequeue_style( ‘woocommerce-layout’ );
    wp_dequeue_style( ‘woocommerce-smallscreen’ );
    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’ );
    }
    }
    }

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support mouli a11n

    (@mouli)

    Hi there,
    I see that you have set the priority of your Add_action to 99 which should make it run late in the wp_enqueue_scripts action which I agree is as you would want it
    The code itself look good to so I suggest that you add some echo statements to confirm that the script is actually running at all.
    For instance you could do something like:
    echo "dequeued styles";
    to indicate that the script ran past that point.

    As you are comfortable with coding yourself and have questions, I would recommend that you join the WooCommerce Slack Community (https://woocommerceslack.herokuapp.com), or the Advanced WooCommerce Facebook group (https://www.facebook.com/groups/advanced.woocommerce).?

    I hope that helps you to figure it out.
    Feel free to get back to us if you have further questions.

    Thread Starter cecowe

    (@cecowe)

    Hey Mouli,

    I’ve been using this code for a long time but now it doesn’t work. I’m not comfortable with coding that’s why I’m ask you for help. ??
    Could you edit the code and paste in the correct way.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Disable All WooCommerce Styles and Scripts Except Shop Pages’ is closed to new replies.