I just cannot figure out what is calling two jquery scripts in my theme. Even if I turn off all plugins, they're still being called. I have not enqueued them in my function.php and also not in my header.php or footer.php.

Could it be that the WP core is calling them? Is there any way to find out?

The two jquery javascripts that are being called are:



I want to defer them or even put them in the footer, but if I don't know from where they're being called, I cannot control them.

It would be great if you had any pointers. Thank you.

  • If you are logged in, I believe WP is using jquery to run the admin bar at the top of the page. What theme are you using? Is it custom or a standard theme? – JakeParis May 23 '15 at 1:26
  • @JakeParis It is a child theme of a theme I found years ago that is not updated anymore. – japanworm May 23 '15 at 9:27

If I am correct, those two js files are "only" loaded by WP itself for use in the back-end(Admin), but not (and WP would not load them if no need for it) in the front-end.

As soon a plugin needs them, they will be loaded (e.g. through a function) in the front-end.
(which seems not in your case because you said 'Even if I turn off all plugins')

What also belongs to be a reason to load those two js files in the front-end, can be inside your Theme. (Think about functions which need them to load/show "stuff")

  • Is it bad? Not at all.
  • Can they be in the footer? Yes they can/should*(performance wise a good solution)*

As mentioned by yourself you could defer them. (which imho is not the optimum solution)

Note: Take a look in 'all' theme files (not only in the child-theme files if you use a child-theme), if there is mentioned anywhere the word jquery or jquery-migrate.min (but I assume you already did).

That said, by using the following function (which can be add in your (child)Theme functions.php file) those two files will be "forced" into the footer.

I hope this helps you a little on your way and maybe is what you where looking for.

 * Force scripts into Footer
 * @link https://developer.wordpress.org/reference/since/4.2.0/
function enqueue_scripts_in_footer() {
wp_deregister_script( 'jquery' ); // https://codex.wordpress.org/Function_Reference/wp_deregister_script
wp_deregister_script( 'jquery-migrate.min' );    
wp_register_script( 'jquery', '/wp-includes/js/jquery/jquery.js', array(), false, true );
wp_register_script( 'jquery-migrate.min', '/wp-includes/js/jquery/jquery-migrate.min.js', array(), false, true );    
wp_enqueue_script( 'jquery', '/wp-includes/js/jquery/jquery.js', array( 'jquery' ), false, true );
wp_enqueue_script( 'jquery-migrate.min', '/wp-includes/js/jquery/jquery-migrate.min.js', array( 'jquery-migrate.min' ), false, true );
add_action( 'wp_enqueue_scripts', 'enqueue_scripts_in_footer' );

As reference to look up what is happening in the function, take a look here:

  • Thank you. It was a nice idea, but unfortunately it only pushes the jquery-migrate into the footer. The jquery main file is still loaded in the header as you can see when you visit my website: zoomingjapan.com – japanworm May 23 '15 at 15:07

jQuery is a part of wordpress core. Its added and included by default. Latest version of Wordpress uses the latest version of jQuery.

It is recommended by wordpress that you don't add your own jQuery file, instead use one which is already there.

The correct way to add jQuery to your WP site is:

function theme_scripts() {
add_action('wp_enqueue_scripts', 'theme_scripts');

Here is the link which I think will be useful for what you are looking for. http://www.ericmmartin.com/5-tips-for-using-jquery-with-wordpress/

  • WP does not enqueue jQuery on all pages by default. – fuxia May 22 '15 at 13:30

If you want to add your own jQuery file you should de-register the built-in jQuery file first: https://codex.wordpress.org/Function_Reference/wp_deregister_script#Example

wp_deregister_script( 'jquery' );

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.