Make WordPress Core

Opened 5 months ago

Closed 4 months ago

Last modified 3 months 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: 6.6
Component: Editor Keywords: gutenberg-merge has-patch
Focuses: css Cc:

Description

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 https://github.com/WordPress/gutenberg/pull/62357 can be brought into core.

Change History (7)

@isabel_brison commented on PR #6750:


4 months ago
#2

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:


4 months ago
#3

I've just put up a PR to fix this in Gutenberg too: https://github.com/WordPress/gutenberg/pull/63331

#5 @isabel_brison
4 months 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:


4 months ago
#6

Thanks for re-testing! Committed in r58703,

@noisysocks commented on PR #6750:


3 months ago
#7

Thanks for committing this early in the 6.7 cycle ❤️

Note: See TracTickets for help on using tickets.