Why to use Bower for your web developement

What is Bower
It is client side package Manager and Great tool to manage all you web dependencies like JavaScript libraries and other assets.


What can be done from Bower
Web sites are made of lots of things — frameworks, libraries, assets, utilities, and rainbows. Bower manages all these things for you.

# registered package
$ bower install jquery

# GitHub shorthand – download repository SOQLBuilder from user Jitendra on Git
$ bower install JitendraZaa/SOQLBuilder

# Git endpoint
$ bower install git://github.com/user/package.git

$ bower install http://somewebsiteURL.com/script.js

How to Install it
I am taking an example of Node to install in bower globally. Below command will install bower and can be used from anywhere
$ npm install –g bower

Current problem
Let’s say you want to use some library like “polymer” or “Jquery”. You will need to search latest version of polymer / JQuery either from main site or from some CDN, then Download zip file, extract and save in your folder. If that library has dependency on some other library then download that library also manually and perform same steps. After some day, your locally saved library may be out of date.

Benefit of Bower
With Bower Simply run this commands in your folder and all dependencies will be automatically fetched and stored in “bower_components” folder
$ bower install –save Polymer/polymer  /*This will download latest version*/

Basic Bower Commands
Below are some basic bower commands:

$ bower list
It will check for latest versions of all components installed by bower in current folder

$ bower list –path
It will show path to be used in your web page for all components installed by bower

$ bower uninstall
If you want to uninstall any previously downloaded library then use this command
Example : $ bower uninstall jquery /*It will remove JQuery*/

$ bower install <libName>#<version>
Install specific version of library. If you want to use older version of library, say 1.11.0 of Jquery, then use below command
$ bower install jquery#1.11.0

Creating and distributing package with Bower
If you have completed development of your application and want to distribute it, lets say on Github. Then use below command

$ bower init

This command will ask some questions and will generate bower.json file. While pushing files on Git, do not push bower folder, push only bower.json. Users can install all dependency of your package by running command

$ bower install

Note :
If you add new dependency after bower.json is generated, it will not be added automatically in JSON file, you need to use “-s” at end of install command.

$ bower install jquery -s  /*Install Jquery and update bower.json*/

Introduction to bower from Jitendra Zaa






2 responses to “Why to use Bower for your web developement”

  1. Harshit Pandey Avatar

    I love bower and specially in building rails and node apps, now with polymer, I saw the best implementation. I find it better over npm and combined with yomen, you go flying speed.

    1. Jitendra Zaa Avatar

      I didn’t knew much about it so thought to explore 🙂 and yeah inspired from ur blog only 😉

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.