[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
Tue Oct 14 00:10:46 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: accepted => closed
* resolution: => fixed
Comment:
In [changeset:"60930" 60930]:
{{{
#!CommitTicketReference repository="" revision="60930"
Editor: Avoid enqueueing assets for blocks which do not render content.
This change prevents scripts, styles, and script modules from being
enqueued for blocks that do not render any HTML content. This is common
for hidden blocks or blocks like the Featured Image block when no image is
present. This change reduces the amount of unused CSS and JavaScript on a
page, improving performance.
A new filter, `enqueue_empty_block_content_assets`, is introduced to allow
developers to override this behavior and enqueue assets for empty blocks
if needed.
The implementation involves capturing the asset queues before and after a
block is rendered. The newly enqueued assets are only merged if the
block's rendered content is not empty. This is done recursively for nested
blocks to ensure that assets for inner blocks are also not enqueued if a
parent block is hidden.
Developed in https://github.com/WordPress/wordpress-develop/pull/9213.
Props westonruter, aristath, peterwilsoncc, gziolo, krupajnanda, dd32,
jorbin.
See #50328.
Fixes #63676.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63676#comment:26>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list