I was writing plugin for combining JS and CSS as three plugins I tried has not worked for me. Dependency problem is where I stopped. It look tough. Then I thought Wordpress can itself help.

How to get list of files in order of dependencies? Is there any WP method for this? Can I use WP_dependency class externally? How?

I am able to filter script files according to Header and Footer.


1 Answer 1


All the information you need you can get from the global variable $wp_scripts:


function wpse124227_wp_script_styles_debug_basic() {
    global $wp_scripts, $wp_styles;
    echo '<pre>';
        print_r( $wp_scripts );
        //print_r( $wp_styles );
    echo '</pre>';
add_filter( 'wp_head', 'wpse124227_wp_script_styles_debug_basic' );

To get a more specific output you have to define what you are looking for, instead of printing the whole object. Below linked information should get you started on that.



I just remembered there is a add-on to the Debug Bar plugin, called Debug Bar List Script & Style Dependencies , which does show scipts and styles dependencies and orders them. But I don't know how the add-on does it, never looked at the code, and if that's exactly what you want. You'd have to inspect that yourself.

  • That I know, but that does not comes in order of dependency. In deps key, dependency is there but it would be big work to get the order based on dependency. So, I thought there would be any way to get in order using WP own's way! Nov 24, 2013 at 15:06
  • Like I said, you have to construct specific output yourself. Dependencies are given in the object, now you only need to order them. @SatyaPrakash Nov 24, 2013 at 15:12

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.