WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a few scripts which are being enqueued,

the problem is that I want to force the order of prominece to which these scripts are loaded. There is one in particular which is loaded from a plugin before the theme ones which requires jquery however the plugin does not require jquery (bad dev on the plugin but I'd rather not touch 3rd party code for futureproofing reasons)

is there some way to mess with the enqueue order at runtime?

Thanks very much

share|improve this question
up vote 5 down vote accepted

You just need to enqueue your scripts before plugin does it. You can do it by setting priority to 0 for your hook. For example, do the following:

add_filter( 'wp_enqueue_scripts', 'wpse8170_enqueue_my_scripts', 0 );
// or if you enqueue your scripts on init action
// add_action( 'init', 'wpse8170_enqueue_my_scripts', 0 );

function wpse8170_enqueue_my_scripts() {
    wp_enqueue_script( 'myscript', 'http://path/to/my/script.js', array( 'jquery' ) );
    // my else scripts go here...

Setting up priority for your hooks will put it to the beginning of calling queue and your scripts will be added first.

share|improve this answer
sorry to be naive but i take it that wpse8170_enqueue_my_scripts_on_init is a custom function with standard enqueue_scripts call in it? – Alex Jun 13 '12 at 8:51
@Alex i have updated my answer, check it out. – Eugene Manuilov Jun 13 '12 at 9:01
This doesn't always work: wordpress.stackexchange.com/questions/91961/… – Dave Kiss May 23 '13 at 16:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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