Where do I append the link rel for jQuery on my HTML file? – Education Career Blog

How do I tell me .HTML file to link the jquery .js file I downloaded?

<html>
    <head>
    </head>
    <body>
        <a href="#">Test</a>
    </body>
</html>

Also, this script for example, where would it go in my .HTML?

$(function(){
    $(".someClass").tipTip();
});

,

The standard template I use for including files in HTML is shown here:

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="style.css">    
</head>
<body>

<script src="jquery.js"></script>
<script src="scripts.js"></script>
</body>
</html>

The main thing to take away is:

  • CSS should always be included before JavaScript
  • The jQuery source file should always be before your other JavaScript files.
  • JavaScript is included at the bottom of the body tag to optimize page loading speed (but some people still prefer to put JavaScript in the Head section.
  • Script tags are now assumed to be JavaScript (but you can always be specific and give it the type=”text/javascript” attribute/value pair).

,

Inside of the <head> is the defacto standard for <script src="file.js"></script> to go. It will be parsed first as a result, though. If you feel that there’s too much overhead from scripts you can dump them before the end body tag so the HTML is parsed beforehand. The latter is not necessary usually, unless there’s lots of code.

Leave a Comment