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
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:
Setting up priority for your hooks will put it to the beginning of calling queue and your scripts will be added first.
To add script before other scripts, use
wp_register_script()
instead ofwp_enqueue_script()
, and then manually add your script to be first at queue: