How would I go about installing 2 versions of jQuery using bower? I want to have v2.0 as well as 1.9.1 for browser support fallback
The issue I'm having is that if you run bower install jquery#1.9.1 jquery#2.0.0
the first version gets overwritten by the second because they are the same component
In the dependencies part of your bower.json you can have something like this:
One shouldn't normally have to do this, but sometimes you have to maintain / migrate an existing website that (for whatever reason) uses different versions of jquery in different pages!
bower.json:
This is how i did it...
"dependencies": {
...
"jquery": "2.0.0",
"jquery-old": "1.9.1"
...
}
Second version, can be any version, old or new. You just have to add a different key. Like jquery-old
Install
bower install --save jquery-old
Use
Now you can use either one of the jquery version:
<script type="text/javascript" src="path/to/bower/directory/jquery/dist/jquery.min.js"></script>
<script type="text/javascript" src="path/to/bower/directory/jquery-old/dist/jquery.min.js"></script>
Bonus
"dependencies": {
...
"jquery": "2.0.0",
"jquery-old": "1.9.1"
"jquery-latest": "^3.3.1"
...
}
From the command line, if you just want the latest 1.x and 2.x versions, you can loosen the constraints in the answer above.
So:
bower install jquery-legacy=jquery#1.10 jquery-modern=jquery#2
would become:
bower install jquery-legacy=jquery#^1 jquery-modern=jquery
According to the bower docs
You can install two different versions of jQuery like so:
Or, if you prefer to set that up in a
bower.json