When we are developing Themes, we are taught to enqueue the jQuery library if necessary, because no jQuery library is available on the front-end of WordPress (if I'm not wrong). But when we are into the Admin Panel of WordPress, WP is using jQuery for various purposes — WordPress back-end, by core, already loading jQuery into its admin area.

So, when we are developing Back-end features for a Theme or Plugin, and we are in need of loading jQuery, is that possible to load jQuery library from WordPress bundle?

I'm asking this because in one of my under-dev. plugin, I added jQuery library-

  • from the jQuery CDN,
  • and as a fallback, from the plugin bundle (using this SO thread)

Now, on every page-refresh my admin panel hits the jQuery CDN, and takes the jQuery lib file from the CDN. If there's no internet connection the php-file-read throws a debug error, but the jQuery loads from my plugin bundle.

But if we can load jQuery from the WP bundle, it'll save time and load of a page, I think.

  • 2
    why can't you use wp_enqueue_script( 'jquery' );? – MortalViews May 23 '14 at 12:00
  • @MortalViews Thanks a lot. That IS the correct answer. Actually I tried that before, but somehow that time it didn't work. Anyways, can you please put that comment as an Answer so that I can mark it as an accepted answer? – Mayeenul Islam May 23 '14 at 12:19

You can load jQuery library using wp_enqueue_script.

jQuery library is registered by default, and the handle is 'jquery'.

for more info check: Handles and Their Script Paths Registered by WordPress and the list at the end of wp_enqueue_script

Note: it is jquery (not jQuery)


 wp_enqueue_script( 'jquery');
| improve this answer | |

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.