how to en-queue jQuery to load before the tag

WordPress Development Asked by Ana on December 2, 2020

I’ve enqueued all my scripts on function.php to load before the tag by passing ‘true’ to the fifth argument. It does works for all of them BUT jquery, any idea what I’m doing wrong?

wp_enqueue_script('modernizr', '', array('jquery'), false, true);
wp_enqueue_script('my-javascript', get_template_directory_uri() . '/js/my-javascript.js', array('jquery', 'modernizr'), false, true);
wp_enqueue_script('jquery-ui', get_template_directory_uri() . '/js/jquery-ui.min.js', array('jquery'), false, true);

One Answer

Try adding this to functions.php


// Custom scripting to move JavaScript from the head to the footer
function remove_head_scripts()
    remove_action('wp_head', 'wp_print_scripts');
    remove_action('wp_head', 'wp_print_head_scripts', 9);
    remove_action('wp_head', 'wp_enqueue_scripts', 1);

    add_action('wp_footer', 'wp_print_scripts', 5);
    add_action('wp_footer', 'wp_enqueue_scripts', 5);
    add_action('wp_footer', 'wp_print_head_scripts', 5);
add_action('wp_enqueue_scripts', 'remove_head_scripts');


Answered by user53340 on December 2, 2020

Add your own answers!

Related Questions

where is admin footer?

1  Asked on December 8, 2021 by alif-azhar


Remove wpautop from retrieve_password_message

1  Asked on December 8, 2021 by scooterlord


WordPress admin display post type tags as checkbox

1  Asked on December 8, 2021 by the-grimmer


Sort by page information by Ascending Numbers

1  Asked on December 6, 2021 by owen-oneill


Multiple meta_query not returning rows

0  Asked on December 6, 2021 by ookmnnsocjvpkcbnml


How to add widget in main menu

1  Asked on December 4, 2021 by mohammad-kashif


Improving wpdb queries with large data

1  Asked on December 3, 2021 by dcp3450


Ask a Question

Get help from others!

© 2022 All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir