Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save interactiveRob/d4fe8b1d32cb54decc5467ecf4ecf9a4 to your computer and use it in GitHub Desktop.
Save interactiveRob/d4fe8b1d32cb54decc5467ecf4ecf9a4 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><div>";
foreach( $wp_styles->queue as $handle ) :
echo "'" . $handle . "',<br/>";
endforeach;
echo "</div>";
}
add_action( 'wp_print_styles', 'se_inspect_styles' );
function se_inspect_scripts() {
global $wp_scripts;
echo "<h2>Enqueued JS Scripts</h2><div>";
foreach( $wp_scripts->queue as $handle ) :
echo "'" . $handle . "',<br/>";
endforeach;
echo "</div>";
}
add_action( 'wp_print_scripts', 'se_inspect_scripts' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment