Upgrade jQuery in WordPress

Generally speaking, you don’t want to touch the versions of libraries used within WordPress admin. But the front-end is another matter entirely, if you’ve built a totally custom theme.

  Change jQuery version, and load it in the footer
function change_theme_jquery() {
  // If not admin, upgrade jQuery to 3.4.1
  if (!is_admin()) :
    wp_register_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js', array(), '3.4.1', true);
add_action('wp_enqueue_scripts', 'change_theme_jquery');

So let me explain this a bit.

We first de-register the built-in version of jQuery, and re-register it with a new version, this time loading from Google’s CDN, and include in the footer instead.

A super-important things to remember is: this function, in isolation, works as expected. If you’re also loading in your own CSS and JS in a similar way, the order you enqueue scripts and styles determines how they’re loaded on the front-end.