I'm on a bit of an efficiency drive. To this end, I would like to check all the scripts and CSS that get enqueued on my multisite setup. I plan to check that they are offloaded to public CDNs if available or some other private static site if I have set that up, while also ensuring there are no duplicates.

Where I am currently stuck (aside from wondering if the extra work actually will save load times at all) is what hook I can use to make sure all the enqueing is done when my script kicks in.

What hook or filter should I use for this purpose?

(Feel free to educate me and any future searchers about anything else I/we should know when attempting this).

1 Answer 1


In terms of the basics, I have learned that there are two actions to hook - wp_print_scripts and wp_print_styles which I understand are called just before they are then added to the header.

add_action( 'wp_print_scripts', 'my_list_scripts' );
function my_list_scripts() {
    global $wp_scripts;
    $enqueued_scripts = array();
    foreach( $wp_scripts->queue as $handle ) {
        // do something clever

add_action( 'wp_print_styles', 'my_list_styles' );
function my_list_styles() {
    global $wp_styles;
    $enqueued_styles = array();
    foreach( $wp_styles->queue as $handle ) {
        // do something clever

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.