Skip to content

Instantly share code, notes, and snippets.

@getify
Created November 16, 2010 15:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save getify/701970 to your computer and use it in GitHub Desktop.
Save getify/701970 to your computer and use it in GitHub Desktop.
how to use jQuery.noConflict() to manage multiple versions of jQuery on same page
<html>
<head>
<script src="jquery-1.3.3"></script>
<script>var $jq133 = jQuery.noConflict(true);</script>
<!-- other stuff -->
<script src="jquery-1.4"></script>
<script>var $jq14 = jQuery.noConflict(true);</script>
<!-- other stuff -->
<script src="jquery-1.4.3"></script>
<script>var $jq143 = jQuery.noConflict(true);</script>
<!-- other stuff -->
<script>
$jq14; // ...
$jq143; // ...
$jq133; // ...
</script>
</head>
<body></body>
</html>
@sakshstore
Copy link

<script src="http://code.jquery.com/jquery-3.4.1.min.js"></script> <script src="http://code.jquery.com/jquery-1.6.3.min.js"></script> <script type="text/javascript"> var $j = $.noConflict(true); </script>

i am using like this,but still this is not working

@santosh-k1
Copy link

@getify If Older jquery is used on master page and latest jQuery used on particular page ... than how we can solved the conflict issue

@getify
Copy link
Author

getify commented Jul 7, 2020

@santosh-k1 see the jquery docs here. in the particular page (that you control):

<script src="latest-jquery.js"></script>
<script>
   var $jqLatest = $.noConflict(true);
 </script>

Now, the jQuery and $ versions should all be the older one from the master page, and the current page should be able to use the latest jQuery from whatever variable name you chose like $jqLatest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment