[wp-trac] [WordPress Trac] #63676: Blocks without rendered content still enqueue scripts and styles

WordPress Trac noreply at wordpress.org
Thu Jul 10 00:37:23 UTC 2025


#63676: Blocks without rendered content still enqueue scripts and styles
-------------------------------------+-------------------------------------
 Reporter:  westonruter              |       Owner:  westonruter
     Type:  defect (bug)             |      Status:  accepted
 Priority:  normal                   |   Milestone:  6.9
Component:  Editor                   |     Version:  5.9
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |     Focuses:  javascript, css,
  needs-unit-tests dev-feedback      |  performance
-------------------------------------+-------------------------------------

Comment (by dd32):

 > That said, i think it would still make sense to do this. I would like to
 see it be overwritable by a filter though.

 Likewise, I should've added that I'm not ''against'' it, only that it
 seems like something that could occur in the wild.  For every reason
 someone has to prevent output from a block, there's a use-case that
 intentionally has no output.

 The way I'd personally have implemented it is by an explicit `return
 false` from the render method than looking for HTML output, but that'll
 irritate purists as I'm pretty sure it currently only returns strings.

 I'm curious why you'd use the HTML tag parser here to detect output rather
 than a more basic `if ( $block_content ) { enqueue assets }` though.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/63676#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list