Soft rejection - wp_enqueue_script

Hi guys,
Recently I got an soft reject for including jQuery library
(There is no need to use the function wp_enqueue_script just to insert jQuery, since jQuery can be called for those scripts which need it passing the argument array(‘jquery’).

Actually I loaded default WP jQuery adding this

wp_enqueue_script('jquery', false, array(), false, false); and I don’t understand what is the reason for the issue.

To be more clear my all code for this looks like this

[code] function twice_register_scripts() {

// Register scripts
// Load jquery UI
wp_enqueue_script(‘jqueryui’, “http” . ($_SERVER[‘SERVER_PORT’] == 443 ? “s” : “”) . “://”);

// Load jquery easing
wp_enqueue_script(‘jqueryeasing’, “http” . ($_SERVER[‘SERVER_PORT’] == 443 ? “s” : “”) . “://”);

// Load google maps
wp_enqueue_script(‘googlemaps’, “http” . ($_SERVER[‘SERVER_PORT’] == 443 ? “s” : “”) . “://”);

/* Load comments script */
if ( is_singular() && comments_open() && get_option(‘thread_comments’) )

wp_enqueue_script(‘jquery’, false, array(), false, false);
/* Media element & player script /
wp_enqueue_script(‘html5media’, get_template_directory_uri() . ‘/js/mediaelement-and-player.min.js’);
Masonry script /
wp_enqueue_script(‘masonry’, get_template_directory_uri() . ‘/js/jquery.masonry.min.js’);
ImagesLoaded script /
wp_enqueue_script(‘imagesloaded’, get_template_directory_uri() . ‘/js/imagesloaded.js’);
Bootstrap script */
wp_enqueue_script(‘bootstrapjs’, get_template_directory_uri() . ‘/js/bootstrap.min.js’);


Thanks :slight_smile:

Not sure if understood your question properly though our best guess is you are looking for this code


function twice_register_scripts() {
wp_register_script('your_script, get_template_directory_uri() . '/js/your_script.js', array('jquery'),'1.1', true);

add_action( 'wp_enqueue_scripts', 'twice_register_scripts' );  

You can use this method too if you want to load jQuery as dependency

function twice_register_scripts() {
    wp_enqueue_script( 'your-script', get_stylesheet_directory_uri() . '/js/your_script.js', array( 'jquery' ) );
add_action( 'wp_enqueue_scripts', 'twice_register_scripts' ); 

As far as I understand, when you use ‘jquery’ as plugin dependency for any one of the plugins, you need not load the default jQuery using wp_enqueue_script as the default jQuery will be loaded automatically then.

This is what I understood from your post. :slight_smile:


@CoderBoys & @anSRThemeAction thanks guys.

I got the soft reject probably because loading jQuery, but I didn’t load the new file and that’s confusing me. Actually I added a function to load a default WordPress jQuery library.

Maybe it’s a problem with loading jQuery UI since I added it from external source. Still not sure what is the problem actually.

Look!! When you call the default jQuery using the dependency (array(‘jquery’)), it’s enough. No need to enqueue the jQuery individually using wp_enqueue_script(). And that’s the case; I am almost certain.

@anSRThemeAction Thanks for the answer.
But how I should call jQuery without wp_enqueue_script() function?

You don’t need to call the default jQuery. It would be automatically called when you used it as a dependency of any scripts as I mentioned again and again. Just delete this code wp_enqueue_script(‘jquery’, false, array(), false, false);
And observe the source whether the jQuery is loaded or not and see the magic.
And of course, don’t forget to let us know the result :slight_smile:

Oh one thing more…
As per as I understand, you have no clear idea of enqueueing scripts using wp_enqueue_script(). Look at the following code calling masonry:

wp_enqueue_script( 'masonry-js', get_template_directory_uri() . '/js/jquery.masonry.min.js', array( 'jquery' ), '4.2.0', true );

Here array( ‘jquery’) is the dependency of the masonry script i.e. this script depends on the jquery and this argument array( ‘jquery’) will automatically call the jQuery. You don’t need to call any.


Thanks a lot man :slight_smile:
It’s working like a charm even I deleted the function for calling jQery.

Cheers and all the best from me.

Be careful! You have to enqueue all other jQuery scripts that are dependent on jQuery library. Just use the code I mentioned in my comment above. It will ensure the serial of the scripts loading after jQuery Library. Thanks much.


Thank you once again. Really appreciate your help.
I was adding that part of code and followed console and it works perfect.

Also I have another problem with directory path which I can’t understand, but will open a new post and describe the problem.