Inline Code
<html>
<head>
<script type="text/javascript">
function a()
{
alert('hello world');
}
</script>
</head>
<body>
:
:
</body>
</html>
External Files
<html>scriptone.js
<head>
<script type="text/javascript" src="/scriptone.js">
</script>
</head>
<body>
:
:
</body>
</html>
function a()
{
alert('hello world');
}
The rule is simple: All script should be external. Both for maintenance and performance.
(Why performance? Because if the code is separate, it can easier be cached by browsers.)