WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If this works (and it's the way people do in a bunch of themes around the web):

    <!-- stuff -->
    <?php wp_enqueue_script('jquery'); ?>
    <?php wp_head(); ?>
<!-- more stuff -->

Why is it recommended to use a hook to enqueue scripts?

add_action('wp_enqueue_scripts', 'my_enqueue_scripts');
function my_enqueue_scripts() {
share|improve this question

Enqueue mechanics and suggested ways to use them serve flexibility and interoperability. Simply put consider what would be the easiest way for third party code to modify mechanics of yours?

Hardcoding things in template often makes editing that template the only viable option. Manipulating hooks is typically more convenient and less problematic than that.

On larger scale there are different opinions and approaches on balance of things between templates and hooks, however enqueue is strongly recommended to be used via hooks in all cases.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.