Where exactly should I attach script in HTML
Posted
by
bzxcv7
on Stack Overflow
See other posts from Stack Overflow
or by bzxcv7
Published on 2012-12-08T22:53:25Z
Indexed on
2012/12/08
23:03 UTC
Read the original article
Hit count: 209
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 matters)
Which way is better and why?
© Stack Overflow or respective owner