WP enqeue script

How to use the wp_enqueue_script in a correct way.

In your header file call the wp_enqueue_script before wp_head, like this:

<?php wp_enqueue_script( 'jquery' ); ?>

<?php wp_head(); ?>

And then put all your javascript code after wp_head.

You can give this function another name but don’t use “my_init_method” because this will conflict with other WP functions.

The only thing you have to do now is to call your javascript using the no-conflict mode. This means that you can’t call the script using the $ shortcode but like this:

// stuff

Comments  Leave a Reply

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!