I’ve tried using both the following source-reference-lines. They both compile. But what is the difference?
1st method:
<script src="~/Scripts/jquery-1.4.1.js" type="text/javascript"></script>
2nd method:
<link href="~/Scripts/jquery-1.4.1.js" type="text/javascript" />
Note: There’s also the similar Difference between script and link as="script" tags which asks about <link href="js/script.js" as="script">, which is different.
linktag is used to relate stylesheets or any other linked documents instead of including javascript files.The HTML Link Element
<link>specifies relationships between the current document and other documents. Possible uses for this element include defining a relational framework for navigation and linking the document to a style sheet.relAttribute:Possible Values:
alternate – An alternate version of the document (i.e. print page, translated or mirror)
stylesheet – An external style sheet for the document
start – The first document in a selection
next – The next document in a selection
prev – The previous document in a selection
contents – A table of contents for the document
index – An index for the document
glossary – A glossary (explanation) of words used in the document
copyright – A document containing copyright information
chapter – A chapter of the document
section – A section of the document
subsection – A subsection of the document
appendix An appendix for the document
help A help document
bookmark A related document
shortcut icon A related (favorite icon) image of the document
While The HTML Script Element
<script>is used to embed or reference an executable script within an HTML or XHTML document.