Skip to content

Instantly share code, notes, and snippets.

@omurphy27
Last active March 8, 2024 07:19
Show Gist options
  • Star 18 You must be signed in to star a gist
  • Fork 11 You must be signed in to fork a gist
  • Save omurphy27/d63222e4940c3afa9d8afd10d9375df4 to your computer and use it in GitHub Desktop.
Save omurphy27/d63222e4940c3afa9d8afd10d9375df4 to your computer and use it in GitHub Desktop.
Wordpress - Print Out All Enqueued Scripts And Styles On A Page
<?php
// add the below to your functions file
// then visit the page that you want to see
// the enqueued scripts and stylesheets for
function se_inspect_styles() {
global $wp_styles;
echo "<h2>Enqueued CSS Stylesheets</h2><ul>";
foreach( $wp_styles->queue as $handle ) :
echo "<li>" . $handle . "</li>";
endforeach;
echo "</ul>";
}
add_action( 'wp_print_styles', 'se_inspect_styles' );
function se_inspect_scripts() {
global $wp_scripts;
echo "<h2>Enqueued JS Scripts</h2><ul>";
foreach( $wp_scripts->queue as $handle ) :
echo "<li>" . $handle . "</li>";
endforeach;
echo "</ul>";
}
add_action( 'wp_print_scripts', 'se_inspect_scripts' );
@michael-pratt
Copy link

Thanks for this, needed a quick way to dump styles and scripts for a page!

@turbulentcat
Copy link

Thanks for this! Was trying to dequeue a heavy and unneeded js file that was incorrectly being queued by a plugin, used this to get its handle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment