Opened 6 weeks ago
Last modified 11 days ago
#64812 new defect (bug)
Scripts: wp_enqueue_registered_block_scripts_and_styles() does not include modules
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Future Release | Priority: | normal |
| Severity: | normal | Version: | 6.5 |
| Component: | Script Loader | Keywords: | good-first-bug has-patch has-unit-tests |
| Focuses: | javascript | Cc: |
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)
#1
@
6 weeks ago
- Keywords needs-patch added
- Milestone changed from Awaiting Review to Future Release
#2
@
5 weeks 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 weeks ago
This ticket was mentioned in PR #11432 on WordPress/wordpress-develop by @arkaprabhachowdhury.
11 days 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
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.