jQuery in header or footer

There is a lot of leftovers in script-related articles in Codex that are not entirely correct (putting it mildly).

The enqueue should not be done before wp_head(), it should be done on wp_enqueue_scripts. Which is technically early inside wp_head().

It doesn’t harm performance, because registering/enqueueing script is merely explaining to WordPress how it should be done. Actual script output is done as separate print action.

See my answer in where is the right place to register/enqueue scripts & styles for more detailed description of how things work.

Leave a Comment