• Hi guys!

    Which is the best way to dequeue/deregister JS and CSS on NO Checkout pages in order to improve loading time of all other pages?

    Any example?
    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Dotstore

    (@dots)

    Hello @sebaros,

    Hope you are doing well!

    Thanks for contacting us.

    here is code

    //* Enqueue scripts and styles
    add_action( ‘wp_enqueue_scripts’, ‘dots_disable_woocommerce_loading_css_js’ );

    function dots_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_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’);

    }
    }
    }

    paste this code on function.php

    Please do let me, if we can assist you further.

    Thank you,
    Multidots

    • This reply was modified 7 years, 10 months ago by Dotstore.
    • This reply was modified 7 years, 10 months ago by Dotstore.
    • This reply was modified 7 years, 10 months ago by Dotstore.
    Thread Starter Sebastian Pendino

    (@sebaros)

    Thank you very much for the code!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to dequeue/deregister JS and CSS on NO Checkout pages?’ is closed to new replies.