Possible Duplicate:
When should I use Inline vs. External Javascript?
Often Javascript needs to be run as soon as possible. For example, suppose I have some radio buttons in a form and when the form fails to submit, the Javascript selects the last button that I selected. If one button is selected by default and the user sees this and then the Javascript changes buttons, it will look weird. Therefore, the script should run as soon as possible and it seems that inlining Javascript might help with this. Is this likely to make a significant difference in terms of reducing how often users see this kind of weird behaviour?
No, you can’t guarantee that your Javascript code will run in time to prevent the user noticing the change, no matter where you put it.
The correct way to do this is to modify the HTML of the form sent from the server, to indicate the user’s previous choice as the
selectedradio button.