Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 7 weeks ago

#52620 closed enhancement (fixed)

Add `path` data to block stylesheets to allow improving their loading method

Reported by: aristath's profile aristath Owned by: gziolo's profile gziolo
Milestone: 5.8 Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: performance Cc:

Description

In Gutenberg we recently merged PR https://github.com/WordPress/gutenberg/pull/28358 to improve loading stylesheets for blocks.
As noted in comment https://github.com/WordPress/gutenberg/pull/28358#commitcomment-46742341 we need to also tweak the register_block_style_handle function to allow 3rd-party blocks to take advantage of these improvements.

Change History (7)

#1 @SergeyBiryukov
5 years ago

  • Milestone changed from Awaiting Review to 5.8

aristath commented on PR #1035:


5 years ago
#2

Nice, thank you for starting this PR. I think we should extend existing unit tests to cover this new style data.

Done in https://github.com/WordPress/wordpress-develop/pull/1035/commits/70f57cf5f0bc0548e08a280325774e29677220be 👍

gziolo commented on PR #1035:


5 years ago
#3

Good, it should be fine to land as soon as the release process for WP 5.7 is finished.

#4 @gziolo
5 years ago

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

In 50836:

Editor: Enqueue script and style assets only for blocks present on the page

Adds styles for individual core blocks to make it possible to render only styles for those blocks that are rendered on the page (frontend). This is optinal functionality for start that can be controlled with the new separate_core_block_assets filter.

In addition to that, styles can be inlined when path is passed when registering an individual styles. This functionality can be changed with the new styles_inline_size_limit filter. The maximum size of inlined styles in bytes defaults to 20 000.

Props aristath, aduth, westonruter, mcsf.
Fixes #50328, #52620.

#5 @SergeyBiryukov
5 years ago

In 50838:

Editor: Some documentation and test improvements for loading separate assets for core blocks:

  • Move should_load_separate_core_block_assets() to a more appropriate place.
  • Update DocBlocks and inline comments per the documentation standards.
  • Document the $wp_styles global in wp_maybe_inline_styles().
  • List the expected result first in unit test assertions.
  • Remove a duplicate unit test.
  • Add missing @covers tags.

Follow-up to [50836], [50837].

See #50328, #52620, #53180.

#6 @johnbillion
4 years ago

In 51065:

Editor: Correct some docblocks added in [50836].

See #50328, #52620.

#7 @westonruter
7 weeks ago

In 60920:

Script Loader: Use original stylesheet URL for sourceURL when inlined.

For inline styles which had been inlined from registered external stylesheets via wp_maybe_inline_styles(), this defers to using the original stylesheet URL for the sourceURL as opposed to fabricating one from the stylesheet handle. This makes the sourceURL much more useful for debugging, as it indicates where the stylesheet is located. This allows a developer to make a change to the CSS more easily.

Developed in https://github.com/WordPress/wordpress-develop/pull/10177.

Follow-up to [50836].

Props westonruter, mukesh27, gziolo.
See #50328, #52620.
Fixes #63887.

Note: See TracTickets for help on using tickets.