Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bower: Install 2 versions of jQuery

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

like image 942
Adam Coulombe Avatar asked May 08 '13 13:05

Adam Coulombe


3 Answers

According to the bower docs

Bower offers several ways to install packages:

# Using the dependencies listed in the current directory's bower.json
bower install
# Using a local or remote package
bower install <package>
# Using a specific version of a package
bower install <package>#<version>
# Using a different name and a specific version of a package
bower install <name>=<package>#<version>

You can install two different versions of jQuery like so:

bower install jquery-legacy=jquery#1.10 jquery-modern=jquery#2

Or, if you prefer to set that up in a bower.json

"dependencies": {
    "jquery-legacy": "jquery#1.10",
    "jquery-modern": "jquery#2"
}
like image 112
buzzedword Avatar answered Nov 09 '22 14:11

buzzedword


In the dependencies part of your bower.json you can have something like this:

"dependencies": {
    "jquery": "2.0.0",
    "jquery-1.9.1": "http://code.jquery.com/jquery-1.9.1.js"
}

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!

like image 44
Andreas Andreou Avatar answered Nov 09 '22 16:11

Andreas Andreou


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

like image 12
Sean DeNigris Avatar answered Nov 09 '22 16:11

Sean DeNigris