Get list of scripts / styles and show file which enqueued them

This is not possible the way you think. It would maybe be possible if you use Reflections or debug_backtrace(), but there’s no reliable way to do this. WordPress does not keep a stack or queue where it tracks file names.

The only thing I could imagine is just hooking into the action and inside wp_enqueue_scripts():

wp_enqueue_scripts

and attach a tracking mechanism of attached callbacks there. Note the s and that this is not the function that you use to attach scripts to the stack.

<?php
/** Plugin Name: (WPSE #152658) Script Loader Callback Inspector */
add_action( 'wp_enqueue_scripts', function()
{
    var_dump( $GLOBALS['wp_filter'][ current_filter() ] );
}, PHP_INT_MAX -1 );

This would leave you with a queue of all attached callbacks. You can then trace them back with your IDE.

Leave a Comment