
外掛標籤
開發者團隊
原文外掛簡介
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.
Four 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
all
blocks + WP global-styles pipeline + theme.json + font-faces + head
