12

When I downloaded the latest version 3.8.1, inside wp-include/js there is a jQuery folder.

Can I assume that WordPress will always include it, meaning I don't have to make my own call? E.g.

wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js', array(), null, false); 
wp_enqueue_script('jquery'); 
2
  • 2
    Yes. Just keep in mind that jQuery is loaded in compatibility mode, so you can't use the $ shorthand notation.
    – Dan
    Apr 7 '14 at 3:08
  • 1
    I don't see it in my recent install of WordPress 5. It's not showing in the source code.
    – Mark
    Jan 7 '19 at 17:05
27

Yes, jQuery is part of WordPress core. But--it can become outdated, because jQuery updates can happen in between WP releases. The recent release of WordPress does use a very recent version of jQuery.

By default,

wp_enqueue_script('jquery') 

grabs jQuery from the core at /wp-includes/js/jquery/jquery.js.

The "correct" way to add jQuery to your WP site is:

function theme_scripts() {
  wp_enqueue_script('jquery');
}
add_action('wp_enqueue_scripts', 'theme_scripts');

Another catch--if you do use the latest jQuery, be careful that it doesn't break plugins.

5
  • 4
    WordPress updates jQuery usually within a couple of days of the jQuery's release itself, but only for the latest beta versions. The jQuery in the latest WordPress will never be very far behind jQuery, so it should never realistically be necessary to use a newer one.
    – Otto
    Apr 5 '14 at 3:32
  • 3
    Always and only use the version of jQuery bundled with WordPress. Do not use a custom version in Themes or Plugins. Apr 5 '14 at 16:07
  • I agree with the two comments above--but, the main problem with jQuery version updates is what I said above--breaking plugins. It's not a critical problem, but one to watch out for.
    – James
    Apr 6 '14 at 3:37
  • Use google cdn.
    – ahmetlutfu
    Apr 6 '14 at 9:39
  • It worked like charm.. Jun 11 '19 at 17:44
5

You still need to enqueue it, but you do not need to register it, as it is registered automatically.

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.