a blog for those who code

Thursday 7 January 2016

Getting started with Bower

In this post we are going to discuss about Bower which is a package manager for the web. So that simply means that Bower can be used to install anything which has to do with the front end like Bootstrap, jQuery, Angular similar to NPM which is used to install back end modules. It keeps track of all frameworks, libraries, assets, utilities and keep them up to date.

PC : http://bower.io/


Bower can be installed using NPM by the following command.

npm install -g bower

The importance of Bower is that it keeps flat package hierarchy which means that it doesn't install the dependencies underneath the things which depends on it. For example Bootstrap depends on jQuery thus bower will install jQuery and Bootstrap on the same level instead of installing jQuery multiple times. This is also known as a flat dependency graph and it helps reduce page load. It works very similar to NPM. Just type bower in the command line you will get set of commands and usage as shown below


To initialize bower we need to run command bower init. Then it will ask some questions like name, description author, licence etc. You can ignore those questions and set the defaults value to each one of them. Once done you will get a bower.json file that has all the answers to all the questions you have answered as shown below.

Package Installation

Install packages using command bower install <package_name>, which installs the package into the folder names bower_components

For example we will install Bootstrap (bower install bootstrap) as shown below.

Please Like and Share the CodingDefined.com Blog, if you find it interesting and helpful.

No comments:

Post a Comment