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

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
);
  • Thanks, didn't realize it was that simple :) – BlueDogRanch Jan 6 at 22:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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