Skip to content

Conversation

@westonruter
Copy link
Member

@westonruter westonruter commented Dec 5, 2025

Trac ticket: https://core.trac.wordpress.org/ticket/64354

TODO

  • Add test for when classic-theme-styles is not enqueued.
  • Add test for when global-styles is not enqueued.
  • Ensure that block styles enqueued at enqueue_block_styles_assets will get printed after classic-theme-styles via enqueue_block_styles_assets().

Note that we do not need to consider what wp_enqueue_registered_block_scripts_and_styles() outputs because it short-circuits if wp_should_load_block_assets_on_demand() is enabled, and wp_hoist_late_printed_styles() will not run when on-demand loading is disabled.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@github-actions
Copy link

github-actions bot commented Dec 5, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props westonruter.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@westonruter
Copy link
Member Author

Cascade when should_load_separate_core_block_assets is disabled:

  1. HEAD > STYLE#wp-img-auto-sizes-contain-inline-css
  2. HEAD > STYLE#wp-emoji-styles-inline-css
  3. HEAD > LINK#wp-block-library-css
  4. HEAD > STYLE#classic-theme-styles-inline-css
  5. HEAD > STYLE#global-styles-inline-css
  6. HEAD > LINK#twentytwenty-style-css
  7. HEAD > STYLE#twentytwenty-style-inline-css
  8. HEAD > LINK#twentytwenty-fonts-css
  9. HEAD > LINK#twentytwenty-print-style-css
  10. HEAD > STYLE#wp-custom-css
  11. BODY > STYLE#block-style-variation-styles-inline-css
  12. BODY > STYLE#core-block-supports-inline-css
  13. BODY > STYLE#core-block-supports-duotone-inline-css

And when should_load_separate_core_block_assets is enabled:

  1. HEAD > STYLE#wp-img-auto-sizes-contain-inline-css
  2. HEAD > STYLE#wp-emoji-styles-inline-css
  3. HEAD > STYLE#wp-block-library-inline-css
  4. HEAD > STYLE#wp-block-archives-inline-css
  5. HEAD > STYLE#wp-block-button-inline-css
  6. HEAD > STYLE#wp-block-categories-inline-css
  7. HEAD > STYLE#wp-block-heading-inline-css
  8. HEAD > STYLE#wp-block-image-inline-css
  9. HEAD > STYLE#wp-block-latest-comments-inline-css
  10. HEAD > STYLE#wp-block-latest-posts-inline-css
  11. HEAD > STYLE#wp-block-buttons-inline-css
  12. HEAD > STYLE#wp-block-search-inline-css
  13. HEAD > STYLE#wp-block-group-inline-css
  14. HEAD > STYLE#wp-block-paragraph-inline-css
  15. HEAD > STYLE#classic-theme-styles-inline-css
  16. HEAD > STYLE#global-styles-inline-css
  17. HEAD > LINK#twentytwenty-style-css
  18. HEAD > STYLE#twentytwenty-style-inline-css
  19. HEAD > LINK#twentytwenty-fonts-css
  20. HEAD > LINK#twentytwenty-print-style-css
  21. HEAD > STYLE#wp-custom-css
  22. HEAD > STYLE#block-style-variation-styles-inline-css
  23. HEAD > STYLE#core-block-supports-inline-css
  24. HEAD > STYLE#core-block-supports-duotone-inline-css

When the block styles are grouped under the related HEAD > LINK#wp-block-library-css entry, the order is:

  1. HEAD > STYLE#wp-img-auto-sizes-contain-inline-css
  2. HEAD > STYLE#wp-emoji-styles-inline-css
  3. HEAD > LINK#wp-block-library-css
  4. HEAD > STYLE#classic-theme-styles-inline-css
  5. HEAD > STYLE#global-styles-inline-css
  6. HEAD > LINK#twentytwenty-style-css
  7. HEAD > STYLE#twentytwenty-style-inline-css
  8. HEAD > LINK#twentytwenty-fonts-css
  9. HEAD > LINK#twentytwenty-print-style-css
  10. HEAD > STYLE#wp-custom-css
  11. HEAD > STYLE#block-style-variation-styles-inline-css
  12. HEAD > STYLE#core-block-supports-inline-css
  13. HEAD > STYLE#core-block-supports-duotone-inline-css

The cascade is the same, with the difference being that block-style-variation-styles, core-block-supports, and core-block-supports-duotone are located in HEAD as opposed to BODY. This is good as it prevents FOUC.

@github-actions
Copy link

github-actions bot commented Dec 5, 2025

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@westonruter westonruter changed the title Preserve original CSS cascade when hoisting late-printed styles Further preserve original CSS cascade when hoisting late-printed styles Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant