Where in the HTML file should Jquery and Bootstrap be placed?

Typically stylesheets in the head and scripts before the closing </body> tag:

<html>
  <head>
    <link rel="stylesheet" href="bootstrap.css">
    <link rel="stylesheet" href="your-other-styles.css">
  </head>
  <body>
    <!-- content -->
    <script src="jquery.js"></script>
    <script src="bootstrap.js"></script>
    <script src="your-other-scripts.js"></script>
  </body>
</html>

You'll want files from vendors such as jQuery and Bootstrap to be included before yours. This means that:

  • CSS: You can override their styles with your own*
  • Scripts: You have access to any objects added to the global scope such as window (jQuery adds $, for example)

However, if you require a script to be available before your content loads (such as Modernizr), then putting it in the <head> ensures it's ready before any of your content.

Including scripts at the bottom ensures that the actual page content is loaded first; when the scripts are finally downloaded the content (DOM) will be ready for your scripts to manipulate.

* assuming your selector specificity is at least equal to those in your vendor CSS


Bottom is best to place all your script references at the end of the page before </body>.It should look like below in normal page.

<html>
 <head>
   <link href="path/to/file.css" rel="stylesheet" type="text/css">
 </head>
 <body>
   <script src="path/to/file.js" type="text/javascript"></script>
 </body>
</html>

Although in some cases it may be necessary to load JavaScript before page load if any of your function need to access JavaScript before Page Load.Specially if you are working with JQuery UI And Bootstrap.

You can decorate your script tags with the defer attribute so that the browser knows to download your scripts after the HTML has been downloaded:

<script src="Jquery.js" type="text/javascript" defer="defer"></script>

or

  <script src="demo_async.js" async></script> 

When present, it specifies that the script will be executed asynchronously as soon as it is available.

http://www.w3schools.com/tags/att_script_async.asp

If you need script to access in page for use then script need to available before using it. Although it need to be sure the browser support defer="defer". Async is supported by all major browsers.

Javascript by default block any other parallel downloads. So if you have many tags in the head, calling on multiple external scripts will block the HTML from loading, thus greeting the user with a blank white screen, because no other content on your page will load until the java script files have completely loaded. Another advantage to load script in bottom is that any error caused by external script will not stop the page from Loading to browser.

Style css need to present in top <Head> to access in page.