In modern web design, jQuery plays an important role in adding client side scripting to web pages. jQuery is widely used to perform various tasks on the client’s browser saving bandwidth and providing a better user experience.
Some example use cases of jQuery include: sliders, lightbox popups, rotating testimonials, etc.
Using jQuery, developers can perform certain actions right in the browser without reloading a page. Some of these actions include navigating a web page, selecting elements on a page to perform actions on them, call Ajax scripts, and handle events like what happens when a user clicks an element.
WordPress comes bundled with jQuery and some essential jQuery libraries. WordPress theme and plugin developers can easily call jQuery in their own plugins and themes to add their own jQuery scripts.
To call jQuery in WordPress theme or plugin, users need to add their own jQuery scripts and enqueue them in WordPress. While enqueuing their scripts, users can call jQuery core or any jQuery plugin that comes with WordPress as a dependency. WordPress automatically loads it along with the user script.
<?php wp_enqueue_script('custom-script', get_stylesheet_directory_uri() . 'https://cdn3.wpbeginner.com/js/custom_script.js', array( 'jquery' )); ?>