0

I'm using this function to load my plugins (custom-logo-and-login) Javascript file in the footer of the login.php page, but the file loads right before the wp-includes main jQuery library:

add_action( 'login_enqueue_scripts', 'login_js_script' );
function login_js_script() {
    wp_enqueue_script( 'login-script', plugin_dir_url( __FILE__ ) . 'scripts.js', null, null, true );
}

How can I force the priority or loading after the main jQuery file? I can't find a way to add a priority. Do I need to unenqueue the main library and enqueue it later than my file?

enter image description here

1 Answer 1

3

If you want to load it after jQuery, you can use script dependency... (3rd param)

For example if your scripts depends on jQuery, you can use:

wp_enqueue_script(
    'login-script', 
    plugin_dir_url( __FILE__ ) . 'scripts.js', 
    array( 'jquery' ),
    null,
    true
);
1
  • Thanks, didn't realize it was that simple :) Jan 6, 2020 at 22:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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