
內容簡介
Zero Blocks Given 外掛旨在優化 WooCommerce 商店的前端效能,透過關閉不必要的區塊 CSS 和 JS,減少資源載入,提升網站速度和使用體驗。
【主要功能】
• 關閉不必要的區塊樣式和腳本
• 提供五種運行模式選擇
• 簡單的設定方式,無需額外介面
• 支援 wp-config.php 常數設定
• 兼容各種 WooCommerce 使用情境
外掛標籤
開發者團隊
原文外掛簡介
Most WooCommerce stores ship 80-150 KB of block CSS and JS that the store never actually renders. The WC BlockPatterns scanner is the one that bugs me most – it hits the filesystem on every request to scan a directory of pattern templates you don’t use. Then add core WP global-styles, wp-block-library and font-faces on top, and you’re loading a Gutenberg frontend you probably switched off a long time ago.
Zero Blocks Given turns it off at the source, through WooCommerce’s own dependency injection container. No CSS dequeue band-aid, no UI checkboxes, no PRO upsell. One constant in wp-config.php, pick a tier, done.
How it works
Here’s the thing – WC registers its block hooks as closures wrapping instance methods on container-managed objects. So you can’t remove_action() them by string. You have to fetch the same instance back from the DI container and pass it in as the callable. That’s what this does:
$bp = \Automattic\WooCommerce\Blocks\Package::container()->get( BlockPatterns::class );
remove_action( 'init', [ $bp, 'register_block_patterns' ] );
The DI-container path is the one that survives WC upgrades cleanly. String-callback matching and dequeue tricks tend to drift every release, so I went with the container.
Five modes. Three ways to set them.
Mode
What it turns off
When to use it
patterns
WC BlockPatterns directory scanner only
Block-based Cart/Checkout – keeps all blocks rendering, just skips the file-I/O scan
blocks
patterns + BlockTypesController + Notices styles + wc-blocks-style handle
Classic-shortcode WC stores
keep-styles
blocks + WC Product Filter pattern scan (ProductFilterAttribute)
Stores that don’t use WC blocks but keep Gutenberg styling – kills the expensive scans, leaves global-styles and core block rendering alone. Pixel-perfect.
all
keep-styles + WP global-styles pipeline + theme.json + font-faces + head
