Can I load javascript code using <link> tag?
No. There was a proposal to allow:
<link rel="script" href=".../script.js"/>
analogously to stylesheets. This is even quoted as an example in the HTML 4 DTD, but browser implementation never happened. Shame, as this would have been much cleaner.
You need to use the <script>
tag to include JavaScript source files:
<script type="text/javascript" src="mysrc.js"></script>
The end tag must be the full </script>
, don't abbreviate the way you can with some tags as in <script type="text/javascript" src="..."/>
.
Yes, alert statements in the included source will appear when they are evaluated by the browser.
For information on the uses of the <link>
tag, see w3.org.