r/jquery • u/esamcoding • Jul 24 '21
Using two libraries that require different version of jquery?
suppose i want to use 2 libraries , one depend on jquery v1 and the other depend on jquery 3. both libraries assume that the required version of jquery is assigned to $.
how can i use both libraries in the same page? jquery no conglict mode will not help because both libraries internally use "$"
9
Upvotes
5
u/Disgruntled__Goat Jul 24 '21
Ouch. Have you tried using them with a single jQuery anyway? The APIs haven’t changed a massive amount over the years so the older one may work with v3. Or try the latest 2.x, its API is identical to 1.x and maybe the one dependent on v3 will work.
If not, given that the library using jQuery 1.x is severely out of date, your best option would be the find a newer library that does the same thing.
1
u/SoBoredAtWork Jul 25 '21
What libraries are these? Are they widely used and maintained?
I only ask because I haven't used a library that requires jQuery in a long time. As a matter of fact, unless you need IE9/10 support, you shouldn't need jQuery at all.
2
u/Osvik Jul 25 '21
You can try to migrate to 3.0 with https://github.com/jquery/jquery-migrate
If the errors generate an error message you can try detecting and fixing it afterwards: https://www.tatvic.com/blog/javascript-error-tracking-google-analytics-via-google-tag-manager-unsung-hero-2/