• Resolved Christian Kormos

    (@darkchris)


    Dear Support,

    Please provide a way to remove unwanted block files (CSS / JS).

    When I remove the wc-blocks-registry.js than it starts to fill up my debug and console.log with warnings

    wp_dequeue_script('wc-blocks-registry');
    wp_deregister_script('wc-blocks-registry');
    [10-Jan-2024 15:07:02 UTC] Payment gateway with handle 'wc-payment-method-bacs' has been deactivated in Cart and Checkout blocks because its dependency 'wc-blocks-registry' is not registered. Read the docs about registering assets for payment methods: https://github.com/woocommerce/woocommerce-blocks/blob/060f63c04f0f34f645200b5d4da9212125c49177/docs/third-party-developers/extensibility/checkout-payment-methods/payment-method-integration.md#registering-assets
    [10-Jan-2024 15:07:02 UTC] Payment gateway with handle 'wc-stripe-block-credit-card' has been deactivated in Cart and Checkout blocks because its dependency 'wc-blocks-registry' is not registered. Read the docs about registering assets for payment methods: https://github.com/woocommerce/woocommerce-blocks/blob/060f63c04f0f34f645200b5d4da9212125c49177/docs/third-party-developers/extensibility/checkout-payment-methods/payment-method-integration.md#registering-assets
    


    Kind regards,
    Krisztian

Viewing 10 replies - 1 through 10 (of 10 total)
  • Stef

    (@serafinnyc)

    I’m not sure if it’s still valid, you’d have to test, but a few years back someone happened to create a way to do so. Again, not sure if it still works, you may need to adjust to your needs. Add to your child theme’s functions.php

    // This removes WooCommerce Scripts on unnecessary pages
    function woocommerce_de_script() {
        if (function_exists( 'is_woocommerce' )) {
         if (!is_woocommerce() && !is_cart() && !is_checkout() && !is_account_page() ) { // if we're not on a Woocommerce page, dequeue all of these scripts
        	wp_dequeue_script('wc-add-to-cart');
        	wp_dequeue_script('jquery-blockui');
        	wp_dequeue_script('jquery-placeholder');
        	wp_dequeue_script('woocommerce');
        	wp_dequeue_script('jquery-cookie');
        	wp_dequeue_script('wc-cart-fragments');
          }
        }
    }
    add_action( 'wp_print_scripts', 'woocommerce_de_script', 100 );
    add_action( 'wp_enqueue_scripts', 'remove_woocommerce_generator', 99 );
    function remove_woocommerce_generator() {
        if (function_exists( 'is_woocommerce' )) {
    	if (!is_woocommerce()) { // if we're not on a woo page, remove the generator tag
    		remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
    	}
        }
    }
    
    // This removes WooCommerce Styles, then add woo styles back in on woo-related pages
    function child_manage_woocommerce_css(){
        if (function_exists( 'is_woocommerce' )) {
    	if (!is_woocommerce()) { // this adds the styles back on woocommerce pages. If you're using a custom script, you could remove these and enter in the path to your own CSS file (if different from your basic style.css file)
    		wp_dequeue_style('woocommerce-layout');
    		wp_dequeue_style('woocommerce-smallscreen');
    		wp_dequeue_style('woocommerce-general');
    	}
        }
    }
    add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_css' );
    Thread Starter Christian Kormos

    (@darkchris)

    Dear @serafinnyc,

    Thanks, but my question is related to the new wc-block scripts, and none of the above codes.

    I removed successfully, that is not a problem for me, but it gives warnings after that, which feels like the core can’t work properly wihout it.

    Stef

    (@serafinnyc)

    This is related to blocks as well. 4th or 5th line down . Again debug and then adjust accordingly.

    I’m not seeing any issues on my end. Could be conflicting with another app or script.

    Thread Starter Christian Kormos

    (@darkchris)

    I think we’re not in the same boat.

    Till WC 8.5.0 we’ve 30+ new scripts thanks to WooCommerce Blocks integration. The code what I mentioned removes them by 1 line, but it shows warning after that in the Console for payment methods like the basic bacs

    Payment gateway with handle 'wc-payment-method-bacs' has been deactivated in Cart and Checkout blocks because its dependency 'wc-blocks-registry' is not registered. Read the docs about registering assets for payment methods: https://github.com/woocommerce/woocommerce-blocks/blob/060f63c04f0f34f645200b5d4da9212125c49177/docs/third-party-developers/extensibility/checkout-payment-methods/payment-method-integration.md#registering-assets

    I reported this to get feedback from the plugin author level member.
    It is something with the payment methods and the wc-blocks.

    Thread Starter Christian Kormos

    (@darkchris)

    Resolved.

    It came from the WooCommerce > Advanced > Funcitons.
    I had to uncheck it.

    Stef

    (@serafinnyc)

    Ah, apologize for that. That feature was released in 8.4 if I’m not mistaken. Glad you were able to get that cleared up.

    @popi0 per forum rules please create your own post as you will not get the help needed in someone else’s post. Thank you.

    Stef sorry: thx to @darkchris. That was it

    Stef

    (@serafinnyc)

    Glad to hear @popi0 have a great day you guys

    Thread Starter Christian Kormos

    (@darkchris)

    @popi0 I’m happy to hear that it fixed your problem also.
    @serafinnyc Thanks for your efforts.

    Have a great day!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘WC 8.5.0 – Provide ways to remove unwanted scripts’ is closed to new replies.