Javascript: Where Should I Put It?
Generally, you should put Javascript in a seperate file for many of the same reasons you put your CSS in a seperate file:
- It will make your code easier to maintain
- It won't make the validator "cough"
- It seperates presentation and structure
We will start by putting our JS in the head of the document simply because it makes the code easier to deal with at first
Inline JS Bad!