Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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