ThisCalculator

Everyday

Load a Different jQuery Version in WordPress Safely

Updated · Standard formula, shown below

Load a Different jQuery Version in WordPress Safely

Loading a different jQuery version in WordPress lets you run older plugins or test new features without breaking your site. This guide shows you how to replace the default jQuery with a specific version, while keeping WordPress core and other scripts working. You’ll need FTP or file manager access, and a basic understanding of WordPress theme files.

What You’ll Need

  • WordPress admin access (to install a plugin or edit functions.php)
  • FTP client or cPanel File Manager (if editing files directly)
  • A code editor (like Notepad++ or VS Code) for safe editing
  • A backup of your site (files + database) before making changes

Step-by-Step

  1. Back up your site. Use a backup plugin or your hosting control panel to create a full backup. This ensures you can restore if something goes wrong.
  2. Decide which jQuery version you need. Check the plugin or theme documentation for the required version. Common versions are 1.12.4 (for old plugins), 3.5.1, or 3.7.1 (for modern compatibility).
  3. Choose your method. You can either use a plugin (e.g., “jQuery Manager”) or edit your theme’s functions.php. The plugin method is safer for beginners; the code method gives more control.
  4. If using a plugin: Install and activate a jQuery version manager plugin from the WordPress repository. Go to its settings page, select the version you want, and save. The plugin will handle loading the correct version.
  5. If using code (theme functions.php): Open your child theme’s functions.php file (if you don’t have a child theme, create one first). Add the following code, replacing ‘3.5.1’ with your desired version:
  6. function custom_jquery_version() {
        wp_deregister_script('jquery');
        wp_register_script('jquery', 'https://code.jquery.com/jquery-3.5.1.min.js', array(), '3.5.1', true);
        wp_enqueue_script('jquery');
    }
    add_action('wp_enqueue_scripts', 'custom_jquery_version');
  7. Save the file and upload it back to your server if you edited locally.
  8. Clear any caching. If you use a caching plugin, purge all caches (page, minify, CDN). Also clear your browser cache.
  9. Test your site thoroughly. Check the front end for JavaScript errors (use browser console), and test the specific plugin or feature that required the jQuery change.
  10. If you used the code method, consider enqueuing jQuery in the footer (true) vs header (false). Most themes expect it in the footer, but if you have issues, switch to false.

Common Mistakes

  • Editing the main theme’s functions.php instead of a child theme. Updates to the parent theme will wipe your changes.
  • Using a version that is too old for your theme’s scripts, causing errors.
  • Forgetting to deregister the default jQuery – you must deregister before registering the new one, otherwise both load.
  • Not clearing all caches – you may still see the old version in your browser.
  • Loading jQuery in the header when your theme expects it in the footer – this can break script dependencies.

Tips

  • Always use a child theme for code modifications.
  • Use the WordPress-hosted jQuery CDN (or a reliable CDN like code.jquery.com) for faster loading.
  • Test on a staging site before applying to production.
  • If using a plugin, keep it updated and check for compatibility with your WordPress version.
  • After switching, run a plugin compatibility check (e.g., using Query Monitor) to spot any errors.

Troubleshooting

  • Site white screen after adding code: This is usually a PHP syntax error. Revert the functions.php file (restore the backup) and check your code carefully.
  • jQuery still loads the old version: Check if another plugin or theme is overwriting your script. Use a plugin like “JQuery Manager” to force the version, or inspect the page source to see which jQuery files are loaded.
  • JavaScript errors on the page: Open browser console (F12) and look for errors. If you see “jQuery is not defined”, your custom script may be loading before jQuery. Move your enqueue to a later priority or use the ‘wp_footer’ hook.
  • Plugin stops working: The plugin may not be compatible with the new version. Try a different version, or check the plugin’s support forum for known issues.
  • Admin area breaks: The admin uses its own jQuery version. Your code only affects the front end. If admin breaks, it’s likely a different issue.

Frequently Asked Questions

Will changing jQuery affect my site’s speed?

It can, but usually not significantly. Older versions are slightly larger, but the difference is minor. Use a CDN and enable caching to minimize impact.

Can I use a different jQuery version for just one page?

Yes, you can conditionally load the script based on page template or ID using conditional tags like is_page().

What is the safest way to revert to the default jQuery?

Remove the custom code from functions.php or deactivate the plugin. WordPress will automatically use its default version.

Does this work with page builders like Elementor or WPBakery?

Usually yes, but page builders often require a specific jQuery version. Test thoroughly after changing.

Will my theme’s built-in scripts break?

Possibly, if they rely on features removed in newer versions. That’s why testing is essential.

Is it better to use a plugin or code?

For beginners, a plugin is safer. For developers who want full control and no extra plugin overhead, code is better.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.