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?
2 Answers
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.
3 Comments
Robert Moskal
If the libraries both expect a globally scoped jquery variable, this isn't going to work.
Dagriel
Yes, that's correct. But if not, the solution is valid.
mpowered
Including jQuery twice isn't a solution... it's just wasteful.
scripttag or through some loader like RequireJS or Browserify? You host them by your own or on some third-party server or CDN?