[wp-trac] [WordPress Trac] #53616: Registered block styles should only be rendered when the block exists on a page

WordPress Trac noreply at wordpress.org
Wed Jul 7 11:16:03 UTC 2021


#53616: Registered block styles should only be rendered when the block exists on a
page
---------------------------+-----------------------------
 Reporter:  aristath       |      Owner:  (none)
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Script Loader  |    Version:  trunk
 Severity:  normal         |   Keywords:
  Focuses:  performance    |
---------------------------+-----------------------------
 Came up in [https://make.wordpress.org/core/2021/07/01/block-styles-
 loading-enhancements-in-wordpress-5-8/#comment-41474 a comment on make].
 In WordPress 5.8 we added the ability to only load styles for blocks when
 these blocks are rendered. However, these optimizations left out block-
 styles that get added using the
 [https://developer.wordpress.org/reference/functions/register_block_style/
 register_block_style()] function/API.

 Registered block-styles can either be added using a handle, or by adding
 directly some CSS, and enqueueing these styles takes place inside the
 [https://developer.wordpress.org/reference/functions/enqueue_block_styles_assets/
 enqueue_block_styles_assets] function.
 If a handle is used and `wp_should_load_separate_core_block_assets`
 returns true, the stylesheet should be enqueued on `block_render`.
 If inline-CSS is used and `wp_should_load_separate_core_block_assets`
 returns true, then we should check if there is a stylesheet for that
 block, and if there is then switch the handle inside the
 `wp_add_inline_style` call from `wp-block-library` to the block's
 stylesheet handle.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/53616>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list