• Resolved sanderrrrr

    (@sanderrrrr)


    Hello,

    I noticed the CSS is loaded on every single page, even when they have nothing to do with PayPal. It would be good to minimize the load only where relevant.

    I have tried the code below, but somehow that is not working.
    Can you advice?

    function disable_woocommerce_loading_css_js() {
    	if(! is_cart() && ! is_checkout() ) { 				
    		wp_dequeue_style('wc-gateway-ppec-frontend'); 
    	}
    }	
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support mouli a11n

    (@mouli)

    @sanderrrrr
    Hi there,
    The code you have shared is simply the definition of a function.
    There is nothing telling it to run so you need to add the following:

    add_action('wp_enqueue_scripts', 'disable_woocommerce_loading_css_js', 100);

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

    Thread Starter sanderrrrr

    (@sanderrrrr)

    Silly mistake from my end, thank you for checking.
    Your code is a bit different; Now I have the code below. Which seems to be working.
    It’s disabled on all pages except the cart and checkout.
    Might be appropriate as default behavior as there is no reason for it to be on all pages.

    add_action('wp_enqueue_scripts', 'disable_woocommerce_loading_css_js' );
    
    function disable_woocommerce_loading_css_js() {
    	if(! is_cart() && ! is_checkout() ) { 				
    		wp_dequeue_style('wc-gateway-ppec-frontend'); 
    
    	}
    }	
    Plugin Contributor Mike M. a11n

    (@mikedmoore)

    Automattic Happiness Engineer

    @sanderrrrr I’m glad it works! Perhaps this would be a good opportunity to create an issue in the open source repository and submit a PR?

    https://github.com/woocommerce/woocommerce-gateway-paypal-express-checkout/issues

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Only load on checkout’ is closed to new replies.