Force wp_enqueue_scripts to the HEADER?

A plugin I’m working on requires jquery to be loaded before the content is processed. Some stock themes, like 2010, 2011 and 2012 (I believe) put the JS in the footer.

How can I force the scripts to be loaded in the header (I will notify users of the plugin that the plugin requires this)?

5 Answers
5

The normal behavior of wp_enqueue_script is to put the script output into the head section, the parameter $in_footer is optional and defaults to false. So, you can load jQuery with your plugin into the head and, assumed your dealing with well programmed themes/plugins, it won’t load again, because wp_enqueue_script prevents this by default – additional information about that here.

Leave a Comment