• I’ve seen function call examples using all 3 of these action hooks to try and accomplish the same thing.

    add_action('init', 'my_enqueue_js_function');
    add_action('template_redirect', 'my_enqueue_js_function');
    add_action('wp_head', 'my_enqueue_js_function');

    If I’m only using a script for a front-end GUI, Would it be a better practice to use ‘init’ to register the scripts and then wp_head to enqueue the scripts? What, if any advantage is there to using template_redirect as opposed to wp_head?

    Thanks in advance to whoever could shed some light.

Viewing 1 replies (of 1 total)
  • Thread Starter Brayne

    (@brayne)

    I see that the codex recommends ‘init’. Just curious as to why some folks would use ‘template_redirect’ or ‘wp_head’ instead?

    Also, I’ve seen some plugin authors use 2 different action calls, 1. to register the script and 2. to enqueue. Isn’t it more efficient to take care of both in the same action call?

Viewing 1 replies (of 1 total)
  • The topic ‘What is the best/proper hook for wp_enqueue_script?’ is closed to new replies.