I have two JS plugins inside my plugin. One uses jQuery 1.7.1 and the other 1.9.1.

I need to have each of them use different version. This is how things are at the moment:

Plugin php file:

wp_register_script('jq-1.9.1-js', 'https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js');
wp_register_script('jq-1.7.1-js', 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js');

Plugin JS file:

    var $j = jQuery.noConflict();

    $j(document).ready(function() {
    // plugin 1
        // options
    // plugin 2
        // options

I searched Google quite a lot and saw solutions for multiple versions but they did not take into account the proper way of including scripts in WP (the use of register and enqueue).

How do I use two versions of jQuery for two JS plugins while still calling scripts the WP way?


  • 4
    Your way of register and enqueue is fine. Although I am not sure why you would need multiple version. Perhaps you might want to reconsider your strategy. If you are creating a plugin with specific jQuery version in mind you can always check the version – Sisir Oct 4 '14 at 8:03
  • Hi Sisir. I need the multiple versions because I am using two JS plugins inside my plugin and one of them requires an old version of jQuery and the second one requires the newer one. If not using my strategy, can you suggest a way around that? Thanks – corre Oct 5 '14 at 9:28

I found that it was better for me to use the latest jQuery version (which WordPress loads by default) and to treat the incompatibility issue by modifying the JS plugin files that were incompatible with the latest jQuery version.

Note: The reason I chose this solution is because in most cases, JS plugin incompatibility with newer jQuery versions is a result of a use of a deprecated method or function in the code and usually replacing the call with a call to an existing function/method will solve the issue and exempt you from including redundant jQuery scripts.

Furthermore, if the plugin will get updated in the future, you should have no problem update the one you currently using because the newer version would probably support the latest jQuery version.

| improve this answer | |

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.