• Hello,

    Is it possible to use you plugin to disable the loading of all Woocommerce script on pages that have no commerce element and have it load only on the pages that are commerce related, such as shop, product, checkout, and cart pages? In the provided link you can clearly see our site is not commerce based. In fact, none of the commerce pages are readily available.

    Here is an example of script I’ve found on the Internet that is supposed to do the above. What I want to know is: can I use your plugin to implement this script instead or writing it directly to the them?

    If is is possible, could you please explain the process were I a WordPress beginner, please?

    Thank you!

    Here is the code in question:

    //* 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’);

    wp_deregister_script( ‘js-cookie’ );
    wp_dequeue_script( ‘js-cookie’ );

    }
    }
    }

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author ImageShea Bunge

    (@bungeshea)

    Hey @nevrsmer,

    You should be able to create a new snippet, paste the code in, activate it, and then see it working. I don’t know a lot about WooCommerce so I can’t verify whether it will work with the latest release of the plugin, but in terms of syntax and general form it looks right to me.

    (Of course, the formatting has been messed up by posting it here, so copy and paste it from the original website, not directly from this page)

Viewing 1 replies (of 1 total)

The topic ‘Disable WooCommerce JS & CSS on Pages Note Commerce-Related?’ is closed to new replies.