Opened 7 weeks ago
Last modified 7 weeks ago
#61779 assigned defect (bug)
block.json - custom block style asset is loaded unconditionally to all pages with a non block-based theme
Reported by: | incrediblewp | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 6.6.1 |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
Wordpress version: 6.6.1.
Description:
When using the block.json method to register a custom block and a regular theme is being used (not a block-based theme), the block style asset is loaded even when the block is not being used. When switching to a block-based theme the block style asset is loaded conditionally.
Note: See
TracTickets for help on using
tickets.
Hi @incrediblewp
This difference between block themes and classic themes is a known limitation, this post explains it better than I can:
https://make.wordpress.org/core/2021/07/01/block-styles-loading-enhancements-in-wordpress-5-8/
In short, in classic themes the styles need to be added to the footer, after the blocks have rendered. And because this can change the loading order of the CSS, breaking the style of existing themes, it was decided to not load the styles conditionally by default in classic themes.
Theme developers can opt-in to loading the styles conditionally.