Commit 58af66272e5 for woocommerce

commit 58af66272e5ed5bdde6d742d72b2c636815fff6e
Author: Vladimir Reznichenko <kalessil@gmail.com>
Date:   Tue Dec 1 11:54:58 2026 +0100

    [Performance] Introduce lazy block registration for cart and checkout blocks (#71316)

diff --git a/plugins/woocommerce/changelog/performance-optimiza-blocks-registration-cart-checkout b/plugins/woocommerce/changelog/performance-optimiza-blocks-registration-cart-checkout
new file mode 100644
index 00000000000..545975f4939
--- /dev/null
+++ b/plugins/woocommerce/changelog/performance-optimiza-blocks-registration-cart-checkout
@@ -0,0 +1,4 @@
+Significance: minor
+Type: performance
+
+Introduced lazy block registration for cart and checkout blocks.
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/mini-cart-contents/block.json b/plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/mini-cart-contents/block.json
index 742353d9c58..fc9968bcc0f 100644
--- a/plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/mini-cart-contents/block.json
+++ b/plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/mini-cart-contents/block.json
@@ -33,6 +33,11 @@
 			"default": "480px"
 		}
 	},
+	"style": [
+		"wc-blocks-style",
+		"wc-blocks-packages-style",
+		"file:../mini-cart-contents.css"
+	],
 	"apiVersion": 3,
 	"$schema": "https://schemas.wp.org/trunk/block.json"
 }
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/payment-method-icons/block.json b/plugins/woocommerce/client/blocks/assets/js/blocks/payment-method-icons/block.json
index 727d6c6b8b7..8e8e395c59c 100644
--- a/plugins/woocommerce/client/blocks/assets/js/blocks/payment-method-icons/block.json
+++ b/plugins/woocommerce/client/blocks/assets/js/blocks/payment-method-icons/block.json
@@ -4,6 +4,12 @@
 	"description": "Display icons for available payment methods.",
 	"category": "woocommerce",
 	"keywords": [ "woocommerce", "payments", "payment methods" ],
+	"editorStyle": "wc-blocks-editor-style",
+	"style": [
+		"wc-blocks-style",
+		"wc-blocks-packages-style",
+		"file:../payment-method-icons.css"
+	],
 	"textdomain": "woocommerce",
 	"attributes": {
 		"numberOfIcons": {
diff --git a/plugins/woocommerce/phpstan-baseline.neon b/plugins/woocommerce/phpstan-baseline.neon
index 48b0a120985..ba4458197a8 100644
--- a/plugins/woocommerce/phpstan-baseline.neon
+++ b/plugins/woocommerce/phpstan-baseline.neon
@@ -48341,17 +48341,6 @@ parameters:
 			count: 1
 			path: src/Blocks/BlockTypes/PaymentMethodIcons.php

-		-
-			message: '#^Method Automattic\\WooCommerce\\Blocks\\BlockTypes\\PaymentMethodIcons\:\:get_block_type_script\(\) should return array\|string but returns null\.$#'
-			identifier: return.type
-			count: 1
-			path: src/Blocks/BlockTypes/PaymentMethodIcons.php
-
-		-
-			message: '#^Parameter \#1 \$arr1 of function array_merge expects array, array\<string\>\|null given\.$#'
-			identifier: argument.type
-			count: 1
-			path: src/Blocks/BlockTypes/PaymentMethodIcons.php

 		-
 			message: '#^Parameter \#1 \$array_arg of function usort contains unresolvable type\.$#'
diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/MiniCartContents.php b/plugins/woocommerce/src/Blocks/BlockTypes/MiniCartContents.php
index a687a8dae69..09629862bb8 100644
--- a/plugins/woocommerce/src/Blocks/BlockTypes/MiniCartContents.php
+++ b/plugins/woocommerce/src/Blocks/BlockTypes/MiniCartContents.php
@@ -9,6 +9,8 @@ use Automattic\WooCommerce\Blocks\Utils\StyleAttributesUtils;
  * @internal
  */
 class MiniCartContents extends AbstractBlock {
+	use EnableBlockJsonAssetsTrait;
+
 	/**
 	 * Block name.
 	 *
@@ -16,26 +18,13 @@ class MiniCartContents extends AbstractBlock {
 	 */
 	protected $block_name = 'mini-cart-contents';

-	/**
-	 * Get the frontend script handle for this block type.
-	 *
-	 * @param string $key Data to get, or default to everything.
-	 *
-	 * @return null
-	 */
-	protected function get_block_type_script( $key = null ) {
-		// The frontend script is a dependency of the Mini-Cart block so it's
-		// already lazy-loaded.
-		return null;
-	}
-
 	/**
 	 * Get the frontend style handle for this block type.
 	 *
 	 * @return string[]
 	 */
 	protected function get_block_type_style() {
-		return array_merge( parent::get_block_type_style() ?? [], [ 'wc-blocks-packages-style' ] );
+		return array_merge( (array) parent::get_block_type_style(), array( 'wc-blocks-packages-style' ) );
 	}

 	/**
diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/PaymentMethodIcons.php b/plugins/woocommerce/src/Blocks/BlockTypes/PaymentMethodIcons.php
index dd6af99b487..499c6a3c0d1 100644
--- a/plugins/woocommerce/src/Blocks/BlockTypes/PaymentMethodIcons.php
+++ b/plugins/woocommerce/src/Blocks/BlockTypes/PaymentMethodIcons.php
@@ -10,6 +10,8 @@ use Automattic\WooCommerce\Blocks\Utils\StyleAttributesUtils;
  * PaymentMethodIcons class.
  */
 class PaymentMethodIcons extends AbstractBlock {
+	use EnableBlockJsonAssetsTrait;
+
 	/**
 	 * Block name.
 	 *
@@ -17,23 +19,13 @@ class PaymentMethodIcons extends AbstractBlock {
 	 */
 	protected $block_name = 'payment-method-icons';

-	/**
-	 * Get the frontend script handle for this block type.
-	 *
-	 * @param string $key Data to get, or default to everything.
-	 * @return array|string
-	 */
-	protected function get_block_type_script( $key = null ) {
-		return null;
-	}
-
 	/**
 	 * Get the frontend style handle for this block type.
 	 *
 	 * @return string[]
 	 */
 	protected function get_block_type_style() {
-		return array_merge( parent::get_block_type_style(), [ 'wc-blocks-packages-style' ] );
+		return array_merge( (array) parent::get_block_type_style(), array( 'wc-blocks-packages-style' ) );
 	}

 	/**
diff --git a/plugins/woocommerce/src/Blocks/BlockTypesLazyController.php b/plugins/woocommerce/src/Blocks/BlockTypesLazyController.php
index fa9c6fdc8b5..76c4fbf4d16 100644
--- a/plugins/woocommerce/src/Blocks/BlockTypesLazyController.php
+++ b/plugins/woocommerce/src/Blocks/BlockTypesLazyController.php
@@ -91,6 +91,8 @@ final class BlockTypesLazyController {
 			$this->get_product_grid_blocks(),
 			$this->get_product_listing_blocks(),
 			$this->get_product_reviews_blocks(),
+			$this->get_cart_and_checkout_blocks(),
+			$this->get_dedicated_pages_blocks(),
 			$this->get_filter_blocks(),
 		);
 		foreach ( $block_groups as $blocks_group ) {
@@ -408,6 +410,41 @@ final class BlockTypesLazyController {
 		);
 	}

+	/**
+	 * Side effect free and stateless cart and checkout blocks.
+	 *
+	 * @return array<string,string>
+	 */
+	private function get_cart_and_checkout_blocks(): array {
+		// CheckoutExpressPaymentBlock: excluded — save_post → express payment attr sync.
+		// MiniCart: excluded — wp_loaded → patterns, hooked_block_types, render_block_context.
+		$list = array(
+			'mini-cart-contents' => \Automattic\WooCommerce\Blocks\BlockTypes\MiniCartContents::class,
+		);
+		if ( ! is_admin() ) {
+			// PaymentMethodIcons overrides enqueue_data() with available payment methods, hence loads eagerly in admin.
+			$list['payment-method-icons'] = \Automattic\WooCommerce\Blocks\BlockTypes\PaymentMethodIcons::class;
+		}
+
+		return $list;
+	}
+
+	/**
+	 * Side effect free and stateless page-template blocks.
+	 *
+	 * @return array<string,string>
+	 */
+	private function get_dedicated_pages_blocks(): array {
+		// SingleProduct: excluded — render_block_context, render_block_core/post-excerpt, render_block_core/post-title.
+		// Cart: excluded — wp_loaded → patterns, wp → emoji disable.
+		// Checkout: excluded — rest_api_init, wp_loaded → patterns, save_post, cart redirect filter.
+		// ClassicTemplate: excluded — render_block filter, enqueue_block_assets.
+		// ComingSoon: excluded — enqueue_block_assets filter.
+		return array(
+			'page-content-wrapper' => \Automattic\WooCommerce\Blocks\BlockTypes\PageContentWrapper::class,
+		);
+	}
+
 	/**
 	 * Side effect free and stateless filter blocks.
 	 *