It's a Package Manager for the web.
1) Go to jQuery website
The traditional way:
2) Download jQuery version 1.11.1
3) Copy and paste the jQuery file into the working directory
4) Manually reference the jQuery file in the correct order inside the working file (i.e. index.html)
5) Next, to install jquery.hammer.js, repeat Step 1 - 4
6) You realise jquery-hammer depends on jQuery 2.0. Repeat Step 1 - 4 to install the correct jQuery version.
bower install -S jquery#1.11.1
bower install -S jquery-hammerjs
Grunt can fix problem 4 - 6
All Bower-registered package must have a bower.json
Introduction of a bower.json file
{
"name": "bootstrap",
"description": "The most popular front-end framework for developing responsive, mobile first projects on the web.",
"version": "3.3.1",
"main": [
"less/bootstrap.less",
"dist/css/bootstrap.css",
"dist/js/bootstrap.js",
"dist/fonts/glyphicons-halflings-regular.eot",
"dist/fonts/glyphicons-halflings-regular.svg",
"dist/fonts/glyphicons-halflings-regular.ttf",
"dist/fonts/glyphicons-halflings-regular.woff"
],
"dependencies": {
"jquery": ">= 1.9.1"
}
}
Bootstrap's bower.json
Focus on the "main" and "dependencies" option
grunt-wiredep
Let's do the necessary setup first
module.exports = function(grunt){
require("matchdep").filter("grunt-*").forEach(grunt.loadNpmTasks);
grunt.initConfig({
wiredep: {
target: {
src:'index.html'
}
}
});
grunt.registerTask('default',['wiredep']);
};
Setup Gruntfile.js
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Untitled</title>
<!-- bower:css -->
<!-- endbower -->
</head>
<body>
<!-- bower:js -->
<!-- endbower -->
</body>
</html>
Insert placeholder into index.html
Ok that's the end of setup. Time to install packages
Install jQuery-hammer
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Untitled</title>
<!-- bower:css -->
<!-- endbower -->
</head>
<body>
<!-- bower:js -->
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/hammerjs/hammer.js"></script>
<script src="bower_components/jquery-hammerjs/jquery.hammer.js"></script>
<!-- endbower -->
</body>
</html>
Install bootstrap
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Untitled</title>
<!-- bower:css -->
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css" />
<!-- endbower -->
</head>
<body>
<!-- bower:js -->
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/hammerjs/hammer.js"></script>
<script src="bower_components/jquery-hammerjs/jquery.hammer.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.js"></script>
<!-- endbower -->
</body>
</html>