=== Zero Blocks Given === Contributors: MythThrazz Donate link: https://marcindudek.dev/ Tags: woocommerce, performance, disable-blocks, gutenberg, zero blocks given Requires at least: 6.0 Tested up to: 7.1 Requires PHP: 8.0 Stable tag: 1.3.3 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html Zero Blocks Given turns off WooCommerce / WP block frontend output at the code level. Five tiers, optional settings, no paywall. == Description == 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 `