Opened 6 months ago
Last modified 5 months ago
#64812 new defect (bug)
Scripts: wp_enqueue_registered_block_scripts_and_styles() does not include modules
| Reported by: | jonsurrell | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Future Release |
| Component: | Script Loader | Version: | 6.5 |
| Severity: | normal | Keywords: | good-first-bug has-patch has-unit-tests |
| Cc: | Focuses: | javascript |
Description
The wp_enqueue_registered_block_scripts_and_styles() function enqueues block scripts and styles. However, it does not include script modules.
The entire function depends on wp_should_load_block_assets_on_demand(). If that function returns true, then not enqueuing anything is the correct behavior.
However, if block assets should be loaded eagerly, then a block's script modules should also be enqueued.
This can break blocks that depend on modules for sites and themes that depend on eagerly loading block assets.
Change History (4)
#2
@
5 months ago
There is a should_load_block_assets_on_demand filter that can also change the behavior of block asset loading.
This ticket was mentioned in Slack in #meta by westonruter. View the logs.
5 months ago
This ticket was mentioned in PR #11432 on WordPress/wordpress-develop by @arkaprabhachowdhury.
5 months ago
#4
- Keywords has-patch has-unit-tests added; needs-patch removed
Adds eager loading support for block view script modules in wp_enqueue_registered_block_scripts_and_styles(), so modules are enqueued alongside existing script/style handles when on‑demand loading is disabled.
Introduces a new PHPUnit test that verifies the module enqueue behavior under eager loading.
Trac ticket: https://core.trac.wordpress.org/ticket/64812
## Use of AI Tools
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
As of 6.9,
wp_should_load_block_assets_on_demand()returns true all sites by default. It only returned true for block themes previously, but it now returns true for classic themes as of #64099. That said, sites can still opt out of loading block styles on demand such as with a plugin.