WordPress provides a way to add external scripts in an elegant way, by using the wp_enqueue_script
function.
The wp_enqueue_script
function is usually used in conjunction with the wp_print_scripts
action and accepts up to four parameters: handle, src, dependencies
, and version
.
handle:
This is the name of the script, it should be a lowercase string.src
(Optional): This is the path to the script from the root directory of WordPress, example:/wp-includes/js/scriptaculous/scriptaculous.js
. This parameter is required only when WordPress does not already know about this script. It defaults to false.dependencies
(Optional): This is an array of the handles of any scripts that this script depends on; which means, that the scripts that must be loaded before this script. Set it to false if there are no dependencies. This parameter is required only when WordPress does not already know about this script. It defaults to false.version
(Optional): This is the string specifying...