What is the point of the dependencies parameter when using wp_enqueue_script()?
For instance, when I do the following:
wp_enqueue_script(
'jscripts',
get_stylesheet_directory_uri() . "/scripts/jscripts.js",
array('jquery-ui-datepicker'));
echo wp_script_is('jquery-ui-datepicker', 'queue')
? '<br>' . '[jquery-ui-datepicker] Script is enqueued' . '<br>'
: '<br>' . '[jquery-ui-datepicker] Script not enqueued' . '<br>';
I get the output 'Script not enqueued' (and the function does not work properly). However, when I do this:
wp_enqueue_script(
'jscripts',
get_stylesheet_directory_uri() . "/scripts/jscripts.js");
wp_enqueue_script('jquery-ui-datepicker');
echo wp_script_is('jquery-ui-datepicker', 'queue')
? '<br>' . '[jquery-ui-datepicker] Script is enqueued' . '<br>'
: '<br>' . '[jquery-ui-datepicker] Script not enqueued' . '<br>';
It works properly and it displays 'script is enqueued'.
Having read the documentation, it would seem like when you specify the handle of dependencies for a script that you are about to enqueue, it will enqueue those dependencies before enqueing it. But, this doesn't seem to be the case. How does this all work?