[wp-trac] [WordPress Trac] #63676: Blocks without rendered content (including blocks via block visibility) still enqueue scripts and styles
WordPress Trac
noreply at wordpress.org
Thu Oct 16 23:31:16 UTC 2025
#63676: Blocks without rendered content (including blocks via block visibility)
still enqueue scripts and styles
-------------------------------------+-------------------------------------
Reporter: westonruter | Owner: westonruter
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 6.9
Component: Editor | Version: 5.9
Severity: normal | Resolution: fixed
Keywords: has-patch needs-testing | Focuses: javascript, css,
dev-feedback has-unit-tests | performance
-------------------------------------+-------------------------------------
Changes (by westonruter):
* status: reopened => closed
* resolution: => fixed
Comment:
In [changeset:"60951" 60951]:
{{{
#!CommitTicketReference repository="" revision="60951"
Editor: Opt to dequeue assets enqueued in hidden blocks, rather than to
enqueue assets for non-hidden blocks.
This eliminates constant emptying out of the queues for styles, scripts,
and script modules before rendering each block. This ensures that
`wp_script_is()`/`wp_style_is()` will return true for assets that are
actually enqueued. The `WP_Script_Modules::$queue` member which was made
public in [60930] is now made private in favor of a
`WP_Script_Modules::get_queue()` method, since there is no need to clear
out the queue before rendering each block and restore after the rendering
is complete.
Finally, as a very special case for unusual blocks which contain
`wp_head()`, a check is done to see if the `wp_enqueue_scripts` action
occurred during the rendering of a block; if so, then no assets will be
dequeued even if no markup is rendered in the block, since it may be that
a script was enqueued for the footer and not the head.
Developed in https://github.com/WordPress/wordpress-develop/pull/10252
Follow-up to [60930].
Props westonruter, dd32, peterwilsoncc, nikunj8866, krupajnanda.
Fixes #63676.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63676#comment:36>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list