Commit b2c7c4e02be for woocommerce
commit b2c7c4e02be7bf269cc14739e3e98ca09403778c
Author: Tung Du <dinhtungdu@gmail.com>
Date: Tue Nov 17 06:02:20 2026 +0700
Read the unified block editor assets flag once per request (#70920)
Every WooCommerce block checks this flag, and each check runs the
option filter again. Keep the first result in a static for the rest
of the request.
diff --git a/plugins/woocommerce/changelog/performance-memo-block-editor-unified-assets-flag b/plugins/woocommerce/changelog/performance-memo-block-editor-unified-assets-flag
new file mode 100644
index 00000000000..bcc973771df
--- /dev/null
+++ b/plugins/woocommerce/changelog/performance-memo-block-editor-unified-assets-flag
@@ -0,0 +1,4 @@
+Significance: patch
+Type: performance
+
+Speed up storefront and editor page loads on sites where a plugin filters the unified block editor assets setting.
diff --git a/plugins/woocommerce/src/Internal/Features/BlockEditorUnifiedAssets.php b/plugins/woocommerce/src/Internal/Features/BlockEditorUnifiedAssets.php
index ecb9328212a..154ac8393c8 100644
--- a/plugins/woocommerce/src/Internal/Features/BlockEditorUnifiedAssets.php
+++ b/plugins/woocommerce/src/Internal/Features/BlockEditorUnifiedAssets.php
@@ -24,14 +24,27 @@ final class BlockEditorUnifiedAssets {
*/
public const OPTION_NAME = 'woocommerce_feature_block_editor_unified_assets_enabled';
+ /**
+ * Whether the feature is enabled, read once per request. Null until the first read.
+ *
+ * @var bool|null
+ */
+ private static ?bool $enabled = null;
+
/**
* Check whether unified block editor assets are enabled.
*
+ * Every WooCommerce block asks this, so the value is read once per request.
+ *
* @return bool True when unified block editor assets are enabled.
*
* @since 11.1.0
*/
public static function is_enabled(): bool {
- return FeaturesUtil::feature_is_enabled( self::FEATURE_NAME );
+ if ( null === self::$enabled ) {
+ self::$enabled = FeaturesUtil::feature_is_enabled( self::FEATURE_NAME );
+ }
+
+ return self::$enabled;
}
}