Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Adding JavaScript to a Bootstrap HTML file

From: Up and Running with Bootstrap 3

Video: Adding JavaScript to a Bootstrap HTML file

Now that we've started index.html, we're going to continue on this file and we're going to add links to a bunch of Javascript features that we need in order for this to work with Bootstrap. This is index.html, if you worked with this file in the last video, we're using the same file in this video. If you missed the last video, if you look in your exercise files folder you'll find a copy of index.html, you can copy it from your exercise files folder to your Bootstrap folder and continue to follow along from this point. So what we needed to do, is we need to make links to three Javascript files.

Adding JavaScript to a Bootstrap HTML file

Now that we've started index.html, we're going to continue on this file and we're going to add links to a bunch of Javascript features that we need in order for this to work with Bootstrap. This is index.html, if you worked with this file in the last video, we're using the same file in this video. If you missed the last video, if you look in your exercise files folder you'll find a copy of index.html, you can copy it from your exercise files folder to your Bootstrap folder and continue to follow along from this point. So what we needed to do, is we need to make links to three Javascript files.

And so the first things that I'm going to make links to are to jQuery and to Bootstrap's JavaScript as well. jQuery is the first thing we need to take a look at. So we're going to go on out on the web, and we're going to go ahead and go to, jQuery dot com. and this is the jQuery website. This is a Java script library, Java script framework that has a tremendous impact on the world. It's used by content management systems and responsive design frameworks and lots and lots and lots of websites.

It's very popular. And what we'll need to do is we'll need to download a copy of Jquery to use with Bootstrap because bootstrap's Javascript relies on jquery. So there's two ways of doing this. One is we can download our own copy of Jquery by going to the download Jquery button here. And then downloading the actual file to our computer and making a link to that. Or, we can use what's called the CDN, the Content Delivery network for JQuery. The difference between these two, if you download your own copy of JQuery and put it on your website, that means that, as long as your website is up, you'll always have access to a copy of jQuery.

However, the argument for using a CDN is, other people may have linked their websites to this same jQuery file, so it may already be downloaded and cached on somebody's computer. And if that's the case, then your website loads that much faster, because one very large element of your website is already downloaded and cached on your computer. The downside to that is if the CDN is off-line, then it's not serving up a copy of jquery. And so your website's not getting a copy of J Query. But that happens very rarely.

So I wouldn't worry terribly much about that. JQuery comes in two versions. There is the 1.0 version, and the 2.0 version. Based on browser support, I'm going to recommend they use JQuery one version. . Because this is going to support Internet Explorer 8, which I know is a concern for a lot of you still. Bootstrap itself, remember, supports Internet Explorer 9 & 10, it can support Internet Explorer 8, with the addition of respond.js which I'm going to walk you through how to add that in just a minute. JQuery 2.0 works with Internet Explorer nine and ten as well.

And if you need it to work with Internet Explorer eight, you'll also want to use the older version of JQuery, the 1.0 branch. Alright, so the line of code that we need then to link to the CDN for JQuery is inside the file that I have in your exercise files folder called additional head code. And you'll find a link to it right here. So in the body of your document, we need to include this little line of code right here. And that includes the URL. So, just above your /body tag, I'm going to put in a comment here. That says' javascript', and I'm going to paste in this line of java script.

Now many of you are probably wondering why I did not put this line of code in the head of my document, because we are usually trained to put java script in the head of the document. The reason why is, as you put lots of files in the head of your document, it's important that their there if they're required for loading the webpage in the way its going to display. Like your style sheets for example, but in this case JQery is responsible for functionality on the page. When you put it in the head of the document, we have to wait for it to download before we can see the rest of the webpage. Which means that it may feel like your website loads quite a bit more slowly.

By putting your JQuery down here in the footer of the document, all of the other information on the page can load first before JQuery loads. Feels like your website is going faster. Because at least something is displaying on the page that you can read while you're waiting for the functionality to load. So that's why we're putting jQuery down here on the bottom. The other thing we're going to add is a link to Bootstraps Java script. So we're going to add that as well. So that's our script tag again. With the source of JS slash Bootstrap.min.js and slash script.

So that is, of course, a link to the min-ified version of the JavaScript inside of the JS folder from Bootstrap. You always want to put this after JQuery. And the reason why is, because this Bootstrap.min.js file is depending on JQuery. So we need' JQuery to load first, followed by the Bootstrap file. So you make sure you put them in this order. The last thing we need to do is get this respond dot 'js' And this is a JavaScript that's designed for helping older versions of IE understand HTML5 semantic markup and other various incompatibilities with Internet Explorer.

So if you will open up your web browser again And I've given you the URL. It's right here in that additional head code document. I'm just going to copy that URL, and paste it right here into my web browser. And, you'll see here, that we have this copy of respond dot js right here. And what we're going to do is we're going to download this copy of respond dot min dot JS. There's a bunch of stuff here. You can download all of it if you wish, but all we really need is this one file. If you click on the name of that one file, this is going to give you everything you need right here.

So, I'm just going to click and drag. Make sure you get all the characters, and I'm going to hold down my shift key as I scroll all the way over to the right here, and click again and make sure you get that final semi colon and I'm going to go ahead and copy that. Then in sublime text I'm making new file. paste in what I was just copied. And I'm going to File > Save that. And I'm going to put that into JavaScript folder. And I'm going to call this respond.js. You can call it respond.min.js or respond.js, whatever you like to do it's fine.

It is of course a minified file. And then, according to the instructions that are here on the website, hit my back button here. You go down and read through the instructions here, it tells you exactly what you needed to do and where exactly you need to put this particular file in order for it to work. So I am going to go ahead and add a link to respond.js in the head of the document, because that's what the instructions say. So I'm going to add a script here, src equals js/respond.js slash script.

And, in the instructions it says if you don't put this in the head of the document. For some of those older versions of IE, you may see a flash of un-styled content before the page will fix itself after respond at JS downloads. That's why we're putting this in the head of the document as opposed to down with the other javascripts. Alright, so if you go ahead and save that document, we now have everything in place to build a Bootstrap website. We've got all of our javascripts that we've gone out on the web and we've collected and downloaded. We've got links to our important documents for Bootstraps style sheets, Bootstraps Javascript and as well as our custom style sheet.

And now you're reading to start building a Bootstrap website.

Show transcript

This video is part of

Image for Up and Running with Bootstrap 3
Up and Running with Bootstrap 3

37 video lessons · 22926 viewers

Jen Kramer
Author

 
Expand all | Collapse all
  1. 5m 25s
    1. Welcome
      58s
    2. Using the exercise files
      1m 19s
    3. Installing Sublime Text 2
      3m 8s
  2. 29m 0s
    1. What is Bootstrap?
      8m 1s
    2. Downloading and unzipping Bootstrap 3
      4m 31s
    3. Examining Bootstrap file structure
      4m 34s
    4. Adding CSS to a Bootstrap HTML file
      4m 35s
    5. Adding JavaScript to a Bootstrap HTML file
      7m 19s
  3. 44m 38s
    1. Exploring Bootstrap's grid system
      9m 10s
    2. Creating new rows and cells
      14m 5s
    3. Adjusting column widths using offset
      5m 2s
    4. Changing column order using push and pull
      5m 34s
    5. Nesting columns
      3m 43s
    6. Creating a JumboTron-style layout
      3m 41s
    7. Challenge: Working with grids
      1m 31s
    8. Solution: Working with grids
      1m 52s
  4. 53m 34s
    1. Exploring basic typography: The small and blockquote tags
      4m 29s
    2. Exploring Bootstrap's responsive classes including .hidden and .visible
      4m 44s
    3. Styling buttons using btn classes
      4m 43s
    4. Styling images with responsiveness and decorative touches
      5m 22s
    5. Incorporating Bootstrap 3 glyph icons
      3m 28s
    6. Creating a thumbnail gallery
      6m 2s
    7. Styling tabular data
      5m 3s
    8. Overriding core CSS with custom styles
      12m 53s
    9. Challenge: Styling panels and callouts
      2m 17s
    10. Solution: Styling panels and callouts
      4m 33s
  5. 27m 41s
    1. Implementing location breadcrumbs
      6m 38s
    2. Using tabs and pills for navigation
      6m 58s
    3. Developing a responsive navigation bar
      9m 9s
    4. Challenge: Modify the "pancake" button
      1m 3s
    5. Solution: Modify the "pancake" button
      3m 53s
  6. 37m 45s
    1. Implementing dropdowns within a navigation bar
      5m 5s
    2. Tabbing within the same page
      15m 45s
    3. Accordion panels with collapse functionality
      11m 37s
    4. Challenge: Tooltips
      1m 59s
    5. Solution: Tooltips
      3m 19s
  7. 3m 0s
    1. Next steps towards advanced Bootstrap
      3m 0s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Up and Running with Bootstrap 3.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.