Exam Development

Adding 3rd Party Libraries

Most 3rd party libraries provide a bower component. Its best practices to use bower to install your 3rd party library. Most libraries provide a bower command to do this.

Search for bower component

If you know the library you want to install, but are unsure of its bower component name, you can search for the component by using bower search <NAME>. Bower will return a list of search result that match.

Install a bower component

Installing a bower component is straight forward. Be sure to include --save-dev to update bower.json with the installation.

bower install <LIBRARY NAME> --save-dev

Your component will be installed in sandbox/bower_components. This is because in the .bowerrc file in our project root, it provides the directory to install components.

Reference a library

You should include library files in sandbox/index.html. CSS files should be included in the header. Script files should be included at the bottom just above body. When you open sandbox/index.html you will see that angular and hammer are being included here.

Uninstall a library

Uninstalling a component is as simple as installing it.

bower uninstall <LIBRARY NAME> --save-dev

If you do uninstall a component, be sure to take any references to it out of your sandbox/index.html and your code.

timer Exercise: Install Underscore.js

From your project root, we will search for underscore.

bower install underscore
Search for underscore

Bower will return a list of results that match our query. Generally the top result is the one you want. In our case, underscore is the name of the bower component.

Install underscore

Let's go ahead and install underscore.