How wp_enqueue_script works?

I am trying to get scripts via wp_enqueue_script();. I have tried this in header but WordPress is not importing any script.

I am using like this wp_enqueue_script('jquery');

http://codex.wordpress.org/Function_Reference/wp_enqueue_script

Is any other step needed for importing script via WordPress?

4 Answers
4

In simple case you need to enqueue script before header scripts are printed, which happens in wp_head hook.

Basic approach would be this in functions.php of your theme:

add_action('wp_enqueue_scripts', 'my_enqueue_scripts');

function my_enqueue_scripts() {

    wp_enqueue_script('jquery');
}

Leave a Comment