I want to show what scripts and styles have loaded on a page and which plugin / theme / file has added them to the page.
We can show all scripts and styles using:
global $wp_scripts, $wp_styles;
var_dump( $wp_scripts );
var_dump( $wp_styles );
Or more elegantly using this answer: How do I get the $handle for all enqueued scripts?
I now want to be able to see where they were enqueued. For example if I had a JS file called foobar.js and it was enqueued by plugins/organge/orange.php I would want to output this file location along with the script.
This is for development to help isolate what is loading what.