Created
December 4, 2025 16:40
-
-
Save westonruter/3772371f6c6aa9fff59f038aee58e87c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #late-enqueued-style-info { | |
| position: fixed; | |
| bottom: 0; | |
| right: 0; | |
| padding: 1em; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Plugin Name: Try Late Enqueued Styles | |
| * Description: Attempting to reproduce the issue described in a <a href="https://make.wordpress.org/core/2025/11/18/wordpress-6-9-frontend-performance-field-guide/#comment-48082">Make/Core comment</a>. | |
| * Author: Weston Ruter | |
| * Author URI: https://weston.ruter.net/ | |
| */ | |
| add_action( | |
| 'wp_body_open', | |
| static function () { | |
| wp_enqueue_style( 'late-enqueued-style', plugins_url( 'style.css', __FILE__ ) ); | |
| } | |
| ); | |
| add_action( | |
| 'wp_footer', | |
| static function () { | |
| ?> | |
| <script type="module"> | |
| const ul = document.querySelector( '#late-enqueued-style-info ul' ); | |
| const link = document.querySelector( 'link#late-enqueued-style-css' ); | |
| const isBlockTheme = <?php echo wp_json_encode( wp_is_block_theme() ) ?>; | |
| let li; | |
| li = document.createElement( 'li' ); | |
| li.textContent = link ? 'β The stylesheet was printed.' : 'β The stylesheet was not printed.'; | |
| ul.appendChild( li ); | |
| if ( link ) { | |
| li = document.createElement( 'li' ); | |
| if ( link.parentElement === document.head ) { | |
| li.textContent = 'β The stylesheet was printed in the HEAD.' | |
| } else if ( isBlockTheme ) { | |
| li.textContent = 'π The stylesheet was not printed in the HEAD due to being block theme.'; | |
| } else { | |
| li.textContent = 'β The stylesheet was not printed in the HEAD.'; | |
| } | |
| ul.appendChild( li ); | |
| } | |
| </script> | |
| <div id="late-enqueued-style-info"> | |
| <strong>Late-enqueued style status:</strong> | |
| <ul></ul> | |
| </div> | |
| <?php | |
| } | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment