Skip to content

Instantly share code, notes, and snippets.

@dviramontes
Created February 18, 2014 04:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dviramontes/9064777 to your computer and use it in GitHub Desktop.
Save dviramontes/9064777 to your computer and use it in GitHub Desktop.
Multiple versions of jquery, same page
<html>
<head>
<link rel="stylesheet" href=" //netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" />
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
</head>
<body>
<div class="jumbotron">
<div class="container">
<p>1. jquery version : </p>
</div>
</div>
<script>
$(function(){
$('p:eq(0)').append(jQuery().jquery).css("color","red");
});
</script>
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<script> var jq = $.noConflict();</script>
<script>
jq(function(){
jq('p:eq(1)').append(jq().jquery).css("color","blue");
});
</script>
<div class="jumbotron">
<div class="container">
<p>2. jquery version : </p>
</div>
</div>
<!-- will load just fine -->
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
</body>
</html>

loading multiple versions of jQuery in one page

for when a CMS allows users to embed script tags which pollute the global name space. jQuery in this case.

A Pen by dreamPilot on CodePen.

License.

body{
padding: 10%;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment