0

I have used the below for many years to move jQuery to the footer.

// Move jQuery to footer
    if( ! is_admin() ) {
        wp_deregister_script( 'jquery' );
        wp_register_script( 'jquery', includes_url( '/js/jquery/jquery.js' ), false, NULL, true );
        wp_enqueue_script( 'jquery' );
    }

But instead of loading the version shipped with WP (or ClassicPress too) I will download the latest version here https://releases.jquery.com/jquery/ to my theme folder.

So how do I now change the wp_register_script above to call a local version like 'assets/js/jquery-3.6.1.js'?

Haven't been able to find any solutions to load jQuery from my theme, only from Google etc which then creates problems for performance.

Thanks in advance.

James Mitchell
  • 123
  • 1
  • 4
  • 1
    See this answer here: [https://wordpress.stackexchange.com/questions/173601/enqueue-core-jquery-in-the-footer](https://wordpress.stackexchange.com/questions/173601/enqueue-core-jquery-in-the-footer) – Moishy Dec 04 '22 at 02:40
  • That is pulling jQuery from the WP core just like my original code above, where as I want to download the latest version and include it in the theme. Hope that makes sense. – James Mitchell Dec 04 '22 at 19:34

1 Answers1

1
if( ! is_admin() ) {
        wp_deregister_script( 'jquery' );
        wp_register_script( 'jquery', get_template_directory_uri() . '/assets/js/jquery-3.6.1.js', false, NULL, true );
        wp_enqueue_script( 'jquery' );
    }
Moishy
  • 3,560
  • 3
  • 23
  • 42