Does Wordpress load jQuery by default?

jQuery(document).ready(function($){ alert("Hi"); }); 

I want to add the jQuery script written above to the WordPress site in the body section, now my question is whether WordPress loads the jQuery library by default or do I need to add <?php wp_enqueue_script('jquery'); ?> <?php wp_enqueue_script('jquery'); ?> over script?

Usually we add <?php wp_enqueue_script('jquery'); ?> <?php wp_enqueue_script('jquery'); ?> when developing plugins for wordpress , but is this the same script queue parameter that is required when adding a jQuery script manually to wordpress? (I'm not going to create a WP plugin, but just want to add jQuery code to a WordPress site)

+8
jquery wordpress
source share
3 answers

Got an answer to my question after some research. Although WordPress comes with built-in jQuery, it does not load the jQuery library by default, we need to add wp_enqueue_script('jquery'); in functions.php

+7
source share

Themes have the ability to download jQuery. It is one thing that some themes use their own version of jQuery (to avoid problems when WordPress updates and updates versions of jQuery). Usually the admin section in jQuery always includes it.

If you can, try writing cross-version jQuery (if you want many sites to use your plugin).

To answer your question directly, it is best to add your own enqueue_script jquery ... it doesn't hurt to have multiple calls for enqueue jquery.

+2
source share

One more step to wp_enqueue_script in the .php file you need to register the .js file (jQuery) using the wp_register_script () source path location. p>

0
source share

All Articles