1

I am writing a web app which uses 2 different JavaScript libraries each with a different Jquery version dependency. How can I specify the Jquery version to use with each library?

6
  • What are the two libraries? Commented Apr 17, 2015 at 18:27
  • Phono.js and Signalr Commented Apr 17, 2015 at 18:27
  • 2
    Have you tried using the latest version with both? Commented Apr 17, 2015 at 18:31
  • How you load those libraries? Simply by script tag or through some loader like RequireJS or Browserify? You host them by your own or on some third-party server or CDN? Commented Apr 17, 2015 at 18:37
  • Using a <script> tag. Commented Apr 17, 2015 at 18:39

2 Answers 2

2

See: https://api.jquery.com/jquery.noconflict/

If for some reason two versions of jQuery are loaded (which is not recommended), calling $.noConflict( true ) from the second version will return the globally scoped jQuery variables to those of the first version.

Sign up to request clarification or add additional context in comments.

3 Comments

If the libraries both expect a globally scoped jquery variable, this isn't going to work.
Yes, that's correct. But if not, the solution is valid.
Including jQuery twice isn't a solution... it's just wasteful.
1

My vote's on forking whichever idiot module doesn't allow you to specify your own jQuery, and removing that requirement. Including jQuery twice is really stupid especially because they're almost guaranteed to be compatible versions.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.