My plugin uses the following to enqueue script in jQuery dependency:

wp_enqueue_script( $plugin_short_slug, plugins_url() . '/' . $plugin_slug . '/js/' . $plugin_slug . '.js', '', array('jquery'), '', true);

If I use it on child theme where I dequeue default WordPress jQuery and load jQuery from CDN in footer, both jQuery and my script land in footer and it works correctly.

Unfortunately when I use plugin on default theme, where default WordPress jQuery is loaded in header, $in_footer is ignored, script appears in header after jQuery and doesn't work despite no errors in console.

I wouldn't like to replace default jQuery or even move it to the footer, because it can break other things for users.

My script is the following, phpVars is properly passed in localized script, above in generated HTML:

var timeout;

jQuery('div.woocommerce').on('change', '.qty', function(){
    if (timeout != undefined) clearTimeout(timeout);        
    timeout = setTimeout(function() {
    }, phpVars.acau_update_delay );


Apparently jQuery dependence makes no difference, if I specify an empty array instead, plugin script is still loaded in header below jQuery and doesn't work, this time only with version parameter instead of both version and jQuery ?ver%5B0%5D=jquery.

1 Answer 1


It's all about poor typo, I put one extra parameter '' before dependency parameter:

wp_enqueue_script( $plugin_short_slug, plugins_url() . '/' . $plugin_slug . '/js/' . $plugin_slug . '.js', '', array('jquery'), '', true);

should be:

wp_enqueue_script( $plugin_short_slug, plugins_url() . '/' . $plugin_slug . '/js/' . $plugin_slug . '.js', array('jquery'), '', true);

Now my script properly loads in footer.

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.