[wp-trac] [WordPress Trac] #54018: Allow scripts registered via block.json to be enqueued in the footer

WordPress Trac noreply at wordpress.org
Wed Jul 19 19:24:29 UTC 2023


#54018: Allow scripts registered via block.json to be enqueued in the footer
---------------------------+--------------------------
 Reporter:  jeremyfelt     |       Owner:  (none)
     Type:  enhancement    |      Status:  new
 Priority:  normal         |   Milestone:  6.4
Component:  Script Loader  |     Version:
 Severity:  normal         |  Resolution:
 Keywords:  has-patch      |     Focuses:  performance
---------------------------+--------------------------

Comment (by westonruter):

 As I just
 [https://github.com/WordPress/gutenberg/pull/52536#issuecomment-1642631741
 commented] on the aforementioned Gutenberg PR, we actually _can_ go ahead
 and mark all view scripts as `defer` (as opposed to `in_footer:true`)
 because they are printed in the footer already for classic themes:

 > When using a classic theme, the view scripts for blocks actually get
 printed in the footer. This is because blocks are parsed in the middle of
 template rendering, which means that view scripts are enqueued too later
 for printing at `wp_head` even though they have `in_footer` set to
 `false`. For block themes, however, parsing is done ''before'' template
 rendering, which means any enqueued block view script ''will'' get printed
 at `wp_head`.
 >
 > Given that classic themes all print in the footer, it seems there is
 absolutely no reason to not add `defer`. This won't really benefit classic
 themes at all, but it will have a big impact for block themes.

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


More information about the wp-trac mailing list