I have read about several ways to embed Javascript in HTML document.
First, in head section:
<head>
...
<script src="abc.js"></script>
</head>
Second, in the end of document’s body:
<body>
<!-- content -->
<script src="abc.js"></script>
</body>
First way is more esthetic, but second version assures that all the items in DOM are loaded. I use HTML5 (but probably it doesn’t matter)
Which way is better and why?
if it is just a library of functions which aren’t suppose to run when the page loads, you can safely put it in the head. Otherwise you need to wrap the code in
abc.jswithwindow.onloador$(document).ready();and then embed it in the head