block.json Registration MethodStarting with WordPress 5.8, extenders were encouraged to begin to utilize block.json to register blocks through a unified registration process. The benefits offered by this update provide consistency and convenience when registering blocks through PHP or JavaScript.
However, while this block.json scanning convention is extremely convenient, it does add additional processing when core blocks are instantiated. On each page load, block registration undergoes the following steps:
block.json files.block.json file is found, read its contents into memory.json_decode on the file contents to convert it to a PHP array.With over 70 core block files to scan and load, this presented an opportunity for optimization.
To reduce filesystem reads and processing of block.json files, which should benefit all WordPress sites and improve performance, block registration has been updated to:
copy:block-json) that scans and converts core block.json files to PHP arrays and stores them in a single blocks-json.php at build time.blocks-json.php file in the register_block_type_from_metadata() function.The addition of an extra build task to compile the decoded JSON data to PHP reduces block registration filesystem reads from ~70 files to just a single file. And since blocks-json.php is a native PHP array, it can be used directly without additional conversion.
The conversion from block.json files to PHP arrays is achieved through the json2php package, which is already utilized in Core and Gutenberg.
Props to @aristath for source material and collaboration, and to @milana_cap for review of this dev note.
WordCamp Asia 2026 brought the global WordPress community to Mumbai, India, from April 9–11, gathering…
WordCamp Asia 2026 will be available to watch live across three days of streaming, making…
April 9-11, 2026 | Jio World Convention Centre, Mumbai, India WordCamp Asia 2026 brings the…
The second Release Candidate (“RC2”) for WordPress 7.0 is ready for download and testing! This…
When WP Engine acquired WPackagist on March 12, the WordPress developer community faced a familiar…
The first Release Candidate (“RC1”) for WordPress 7.0 is ready for download and testing! This…