Make WordPress Core

Opened 5 weeks ago

Closed 5 days ago

Last modified 5 days ago

#61395 closed enhancement (fixed)

Enqueue block custom CSS only when block renders on the page.

Reported by: isabel_brison's profile isabel_brison Owned by: isabel_brison's profile isabel_brison
Milestone: 6.7 Priority: normal
Severity: normal Version: trunk
Component: Editor Keywords: gutenberg-merge has-patch
Focuses: css Cc:


Currently, block-specific custom CSS defined in theme.json or the global styles UI gets enqueued whether the block is on the page or not.

Custom CSS logic needs to be updated to more closely follow that of other global styles, so that block custom CSS can be enqueued conditionally in the same way as block global styles currently are.

Some of the changes from can be brought into core.

Change History (6)

@isabel_brison commented on PR #6750:

5 days ago

Thanks for reviewing, folks!

Can anyone reproduce this issue, or is it just my environment?

I could reproduce that locally; it was due to a missing check that made sure dequeuing customizer CSS only happened for block themes. I've replaced the check now so things should work exactly as they do in trunk.

@isabel_brison commented on PR #6750:

5 days ago

I've just put up a PR to fix this in Gutenberg too:

#5 @isabel_brison
5 days ago

  • Owner set to isabel_brison
  • Resolution set to fixed
  • Status changed from new to closed

In 58703:

Editor: enqueue block custom CSS only when block renders on the page.

Updates the global styles custom CSS handling logic to be consistent with other global styles and take advantage of conditional enqueuing of block styles.

Props isabel_brison, aaronrobertshaw, andrewserong.
Fixes #61395.

@isabel_brison commented on PR #6750:

5 days ago

Thanks for re-testing! Committed in r58703,

Note: See TracTickets for help on using tickets.