Adding jQuery and Bootstrap to Write a Mobile-Friendly and Responsive Web Application
In Part 1 of this series, we set up a basic HTML 5 project using Netbeans as our IDE, and we also presented a few elements that have been added in this new specification of the language.
In this article we will introduce you to jQuery and Bootstrap, two priceless utilities to write HTML 5 code more easily. Both jQuery and Bootstrap are licensed under the MIT and Apache 2.0 licenses, which are compatible with the GPL and are thus free software.
Incorporating jQuery and Bootstrap into Our Project
To download jQuery, go to the project’s web site at http://jquery.com and click on the button that displays the notice for the latest stable version.
At the time of this writing it’s v1.11.3 for full-browser compatibility (including Internet Explorer versions 6, 7, and 8) or v2.1.4 if you’re sure that your visitors will not be using those versions of IE.
We will go with this second option in this guide. DO NOT click on the download link yet (the following illustration is only meant to indicate which is the right option).
You will notice that you can download either a compressed
.min.js or an uncompressed
.js version of jQuery. The first is meant specially for websites and helps reduce the load time of pages (and thus Google will rank your site better), while the second is targeted mostly at coders for development purposes.
For the sake of brevity and easiness of use, we will download the compressed (also known as minified) version to the scripts folder inside our site structure.
Right click on the link for the compressed, production version and choose Save Link As…, and then navigate to the indicated directory (you may want to refer to the path indicated where we chose to save our project in Part 1).
Finally, click Save on the bottom of the current dialog:
Now it’s time to add Bootstrap to our project. Go to http://getbootstrap.com and click on Download Bootstrap. On the next page, click on the highlighted option as indicated below to download the minified components, ready to use, in a zip file:
When the download completes, go to your Downloads folder, unzip the file, and copy the highlighted files to the indicated directories inside your project:
# cd ~/Downloads # unzip -a bootstrap-3.3.5-dist.zip # cd bootstrap-3.3.5-dist
# cp css/bootstrap.min.css /home/gabriel/NetBeansProjects/TecmintTest/public_html/styles # cp fonts/* /home/gabriel/NetBeansProjects/TecmintTest/public_html/fonts # cp js/bootstrap.min.js /home/gabriel/NetBeansProjects/TecmintTest/public_html/scripts
If you now expand the structure of your site in Netbeans, it should look as follows: