I've got a conflict with another plugin which is blocking the JS in my custom plugin with the hook:
add_action('wp_enqueue_scripts', '<FOREIGN-PLUGIN>');
Is there a way to enqueue my JS before all other plugins?
I tried already to set priority like
add_action('wp_enqueue_scripts', '<FOREIGN-PLUGIN>', 1);
add_action('wp_enqueue_scripts', '<MY-PLUGIN>', 2);
but it doesn't work. Any ideas?
I've got a conflict with another plugin which is blocking the JS in my custom plugin with the hook:
add_action('wp_enqueue_scripts', '<FOREIGN-PLUGIN>');
Is there a way to enqueue my JS before all other plugins?
I tried already to set priority like
add_action('wp_enqueue_scripts', '<FOREIGN-PLUGIN>', 1);
add_action('wp_enqueue_scripts', '<MY-PLUGIN>', 2);
but it doesn't work. Any ideas?
Use dependencies. Dependencies are scripts that your script relies upon to be loaded first. The <FOREIGN-PLUGIN>
in the example should be the handle that script was enqueued with.
$deps = array('<FOREIGN-PLUGIN>');
wp_enqueue_script( $handle, $src, $deps);
remove_action()
to remove the other plugin's action, add yours, then add back the other plugin's action? – Sally CJ Commented Oct 16, 2019 at 2:07wp_deregister_script( 'script-handle' )
then enqueue your script, other script. To register script:wp_register_script(....parameters....)
and to enqueue script :wp_enqueue_script('script-handle')
– maverick Commented Oct 16, 2019 at 6:48