I am currently using a child theme of the Hueman theme.

I am filtering the different JS scripts, page by page.

So, I use the following function, in order to display which scripts are used:

// Finding handle for your plugins
function display_script_handles() {
    global $wp_scripts;
    if(current_user_can('manage_options') && ! is_admin()){ # Only load when user is admin
    foreach( $wp_scripts->queue as $handle ) :
         $obj = $wp_scripts->registered [$handle];
         echo $filename = $obj->src;
         echo ' : <b>Handle for this script is:</b> <span style="color:green"> '.$handle.'</span><br/><br/>';
    echo '<p style="color:red;font-weight:600;font-size:2em;">Nombre de scripts : '.$id.'</p>';
add_action( 'wp_print_scripts', 'display_script_handles' );

Then, I load the homepage in order for me to see these handles. However, I can see that wp_print_scripts runs twice.

Is that an issue ? Does it mean that each script is loaded twice ?

Besides, each time it runs, it displays a different number of scripts. Maybe there's a reason for it ?

Thank you for your help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.