jQuery has the function jQuery.noConflict
to circumvent conflict errors. It was originally made to resolve conflicts with other libraries that also define the object $
, but can be used to use multiple versions of jQuery.
<script src="assets/vendor/jquery/jquery-3.3.1.min.js"></script>
<script>
const $jQ3_3_1 = jQuery.noConflict();
</script>
<script src="//code.jquery.com/jquery-1.12.4.js"></script>
<script>
const $jQ1_12_4 = jQuery.noConflict();
</script>
That is, as soon as you add jQuery 3.3.1 you use the function noConflict
to create the $jQ3_3_1
, as well as after you add jQuery 1.12.4 you use again to create the instance $jQ1_12_4
, using every instance you need.
But this is probably unnecessary. Using jQuery in an application today is questionable; using two is even more so. Not worth adding all the payload that the library requires only to use a Feature. If it’s a plugin that you need, I recommend that you look for something updated and use only one of the versions in the application.
Out of curiosity, why you need different versions?
– Woss
the latest controls the graphs, tables... basically the project structure and the older ones control my autocomplete input.
– Ronaldo de Lima
Wouldn’t it be the case to create an autocomplete component with a more updated version and thus keep your libraries always up to date? It is more feasible to change all tables, charts, etc.
– Victor Laio