I am including jQuery in my header.php file like this:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>

But when doing this, it breaks my home page slider, it breaks my google maps ultimate plugins and some other things. When I exclude it, no custom jQuery runs on my page...only the slider works which must be using jQuery...

So if jQuery is already running on my site (since I have jQuery easing in the theme etc..), why is custom jQuery code I add to my files in tags not working? However, when I include jQuery like I said above, my custom code runs, but it breaks other plugins...

Why is that?


You should not include jQuery manually. jQuery is included in WordPress by default, but isn't loaded on every page unless a plugin or theme requests it. This can be done using:

function my_scripts() {

Here is function reference for wp_enqueue_script (the function) and wp_enqueue_scripts (the action hook).

In addition to that, WordPress is using jQuery in no-conflict mode. This means you cannot use the normal $() function, but have to use jQuery() instead. For example, instead of this:


Use this:

  • 1
    While it is undoubtedly worth mentioning noConflict mode: closures with $ as an argument are the way to go. IMHO, that is. – Johannes Pille Mar 17 '13 at 16:54

jQuery is included in WordPress by default. There is no need to add it to a theme's header file manually.

If, when omitting manual addition, your script(s) are not working as expected, you probably include them too early, i.e. before wp_head() has run.

Also, it suggests you are not including them as you should, since then things would take care of themselves. Take a look at the wp_register_script and wp_enqueue_script functions.

  • 1
    Or there is a jQuery version conflict that is causing fatal errors. +1 though. – s_ha_dum Mar 17 '13 at 16:46
  • Fair. Enuff. :) – Johannes Pille Mar 17 '13 at 16:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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