Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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'); 
share|improve this question
    
Yes. Just keep in mind that jQuery is loaded in compatibility mode, so you can't use the $ shorthand notation. –  Dan Apr 7 at 3:08

2 Answers 2

up vote 6 down vote accepted

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.

share|improve this answer
2  
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 at 3:32
1  
Always and only use the version of jQuery bundled with WordPress. Do not use a custom version in Themes or Plugins. –  Chip Bennett Apr 5 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 at 3:37
    
Use google cdn. –  ahmetlutfu Apr 6 at 9:39

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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