Timeline for How to load the WordPress jquery in the <head> section
Current License: CC BY-SA 3.0
9 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 7, 2017 at 6:24 | comment | added | vhs | Scripts should be explicitly dequeued before being enqueued again. | |
Aug 25, 2013 at 19:37 | vote | accept | John Doe | ||
Aug 25, 2013 at 19:16 | comment | added | Vinod Dalvi | One thing is you are using wp_head hook instead of wp_enqueue_scripts which is recommended for adding scripts and other is the last parameter of wp_enqueue_script() function is boolean stating whether to include it in footer which i have set to false. See it here codex.wordpress.org/Function_Reference/wp_enqueue_script | |
Aug 25, 2013 at 19:03 | comment | added | John Doe |
A theme change makes no difference. To summarise, with all plugins disabled, an attempt to add jquery with function insert_jquery(){ wp_enqueue_script('jquery'); } add_filter('wp_head','insert_jquery'); loads jquery in the footer, whereas using the above code instead loads it in the <head> tag as it should do. I don't understand this behaviour.
|
|
Aug 25, 2013 at 17:51 | comment | added | Vinod Dalvi | No they don't do that while disabling. Try changing theme to other theme like default twentytwelve theme and then check it. | |
Aug 25, 2013 at 17:48 | comment | added | John Doe |
I don't see what can be forcing jquery to load in the footer when every single one of my plugins are disabled. Can they do that while they are disabled?
|
|
Aug 25, 2013 at 17:41 | comment | added | Vinod Dalvi | It is just adding script in the header which is required for your slideshow to work but as some of your plugins were adding it in footer as there may be some functionality of those plugins which need this script in footer will not work properly. | |
Aug 25, 2013 at 17:36 | comment | added | John Doe |
I find that including this exact function code in my child theme's functions.php file places jquery successfully in the <head> again and thus re-enables my slideshow. That's great, but I'm still puzzled, as you seemed to imply that its purpose was to prevent some 'rogue' plugin from placing jquery in the footer - but all my plugins are disabled. So what is it overriding?
|
|
Aug 25, 2013 at 17:07 | history | answered | Vinod Dalvi | CC BY-SA 3.0 |