Skip to content

Instantly share code, notes, and snippets.

@westonruter
Created December 4, 2025 16:40
Show Gist options
  • Select an option

  • Save westonruter/3772371f6c6aa9fff59f038aee58e87c to your computer and use it in GitHub Desktop.

Select an option

Save westonruter/3772371f6c6aa9fff59f038aee58e87c to your computer and use it in GitHub Desktop.
#late-enqueued-style-info {
position: fixed;
bottom: 0;
right: 0;
padding: 1em;
}
<?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