1

Easy Question: If I enqueue a script as follows:

Version A:

wp_enqueue_script('my-script', plugins_url( '/path/to/file', __FILE__ ), array('jquery', 'jquery-ui-core'));

Do I need to enqueue jquery and jquery-ui-core? As below:

Version B:

wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'jquery-ui-core' );
wp_enqueue_script('my-script', plugins_url( '/path/to/file', __FILE__ ), array('jquery', 'jquery-ui-core'));

Or does listing the scripts that it's dependent on (as in Version A) automatically handle that?

3

You can use the first one, as long as the scripts have been registered, it will enqueue the dependencies prior if they haven't already. JQuery etc should already have been registered so version A is perfectly fine

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.