Why is jquery-ui-core enqueueing in my footer instead of the header?

Why do you need it in the header?

It’s enqueuing in the footer because when it was registered it was set to enqueue in the footer.

In wp-includes/script-loader.php:

$scripts->add( 'jquery-ui-core', '/wp-includes/js/jquery/ui.core.js', array('jquery'), '1.8.12' );
$scripts->add_data( 'jquery-ui-core', 'group', 1 );

The second line forces it to load in the footer. You could deregister the script, then re-enqueue it in the header:

<?php
add_action('wp_enqueue_scripts', 'zg_load_scripts');
function zg_load_scripts(){
    if( is_admin() ) return;
    wp_deregister_script( 'jquery-ui-core' );
    wp_enqueue_script( 'jquery-ui-core', site_url(  '/wp-includes/js/jquery/ui.core.js' ), array('jquery'), '1.8.12' );
}

Leave a Comment