Safely loading jQuery onto WordPress web pages
When working on a project that would benefit from the jQuery library, it might be tempting to provide your own copy of jQuery or to access a copy from the Google API website. However, there is no need to do this as WordPress provides a copy of jQuery as part of its installation and makes it very easy to load.
By using the appropriate utility function to load jQuery, developers make a request to WordPress to load this library instead of doing it themselves. Once all the requests have been received, they are analyzed for duplicates. Then, a single instance of each script is loaded to reduce the chance of conflicts between multiple copies of the same library.
Getting ready
You should have access to a WordPress development environment.
How to do it...
Follow these steps to load the jQuery library for use on front-facing website pages:
- Navigate to the WordPress
plugins
directory of your development installation. - Create...