Site logo

Archived topic

How to enqueue jQuery in the header and not from the footer

3 replies · Started by Gregory on November 16, 2021

Viewing posts 1–4 of 4

I found this solution provided by Tom

add_action( 'wp_enqueue_scripts', 'tu_load_jquery' );
function tu_load_jquery() {
    wp_enqueue_script( 'jquery' );
}

jQuery is now loaded in the header but the problem is it has "defer" script tag. Anyway to implement this without the defer tag?

Hi Gregory,

Enqueuing doesn't add defer attribute by default. It's likely a plugin that's adding it.

Can you try disabling ALL plugins except GP Premium and see if it still occurs?

Yup, its confirmed, SiteGround Optimizer plugin is adding the defer attribute. Just excluded the files from the deferral. Thanks!

No problem. Let us know if the issue is resolved or if you need further help w/ this. :D

This archived topic is closed to new replies.