Loading specific jQuery version in WordPress plugin development

I’m diving into WordPress plugin creation and have a question about jQuery management.

How can I ensure my plugin uses a particular jQuery version? Some WordPress themes don’t include jQuery at all, while others ship with outdated versions. What’s the best approach when my plugin requires newer jQuery features?

add_action('wp_enqueue_scripts', 'register_my_jquery');
function register_my_jquery() {
    wp_enqueue_script('jquery');
}

I found this snippet online, but I’m wondering if it just loads whatever jQuery version exists in the active theme (assuming there is one).

Would it be smarter to bundle my own jQuery file within the plugin directory and load that instead? If so, how should I modify the above function to point to my custom jQuery version rather than relying on the theme’s implementation?

Any guidance would be appreciated!

WordPress ships with its own jQuery that updates with each core release. When you use wp_enqueue_script('jquery'), you’re getting WordPress’s bundled version, not what your theme includes. The version matches your WP install - newer WordPress means newer jQuery.

I’ve been building plugins for five years and here’s what I learned: don’t deregister WordPress jQuery to load your own. It creates way more problems than it fixes. Plugin conflicts become a total nightmare when multiple plugins try this.

Write your code to work with whatever jQuery WordPress provides instead. Most jQuery features haven’t changed in years anyway. Need cutting-edge stuff? Plain JavaScript usually handles it better.

WordPress jQuery gets tested against thousands of themes and plugins, so it’s your safest bet for compatibility.

WordPress comes with jQuery built-in, so you don’t need to add it yourself. That code loads WordPress’s jQuery, which runs in noConflict mode - meaning you’ll use jQuery instead of $. Don’t bundle your own jQuery version. I made this mistake and it broke other plugins on my client sites. If you absolutely need a different jQuery version, use wp_deregister_script() then wp_register_script(). But honestly? Ask yourself if you really need newer jQuery features. You might get the same results with vanilla JavaScript or WordPress’s existing jQuery. Modern browsers handle JavaScript way better now, so jQuery isn’t as necessary as it used to be.

yep, don’t bundle it! using your own jQuery can mess things up with other plugins. just stick to the one that comes with WordPress. if you really need a diff version, try wp_register_script with a CDN instead, but def test it first. learned the hard way!