[wp-trac] [WordPress Trac] #50328: Enqueue script and style assets only for blocks present on the page

WordPress Trac noreply at wordpress.org
Mon Jun 15 19:01:32 UTC 2020


#50328: Enqueue script and style assets only for blocks present on the page
-------------------------+------------------------------
 Reporter:  aduth        |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Editor       |     Version:
 Severity:  normal       |  Resolution:
 Keywords:               |     Focuses:  javascript
-------------------------+------------------------------

Comment (by westonruter):

 Cross-posting
 [https://github.com/WordPress/gutenberg/issues/21838#issuecomment-643657946
 Gutenberg issue comments] where I've raised a concern about FOUC:

 > Has it been considered to not just enqueue the scripts and styles but
 rather print them instead? This will reduce the risk of a flash of
 unstyled content, as otherwise enqueued assets will get printed at
 `wp_footer`, correct?
 >
 > I took this approach in the [https://github.com/westonruter/syntax-
 highlighting-code-block Syntax-highlighting Code Block] plugin. It's
 definitely not as clean as just deferring to enqueue in
 [https://github.com/WordPress/gutenberg/pull/22754 gutenberg#22754], but
 it did address FOUC.
 >
 > See also [https://github.com/studiopress/atomic-blocks/pull/294 atomic-
 blocks#294] & [https://github.com/studiopress/atomic-blocks/pull/297
 atomic-blocks#297] which do this for Atomic Blocks, to conditionally print
 the Font Awesome stylesheet before the first dependent block in the page.

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


More information about the wp-trac mailing list