In general, we never should have embed JavaScript inside the same file as the HTML markup and should instead place the JavaScript into an external file.
The content, presentation, and interaction code should all be separate to make your life easier as a website developer.
- Cleaner Code. Cleaner code is much quicker to find errors in, and will reduce the complexity. In addition, changes only need to be made in one file instead of in potentially dozen resulting in a significant saving of your time and money for your client.
- JavaScript will be better cached for future use and will reduce the size of the HTML file. Users won’t need to download the file every time the user revisits resulting in very quick retrieval.
- Different Parsing Systems. The parsing systems used for HTML/XHTML are vastly different from the parsing/compiler systems used for JavaScript are different and can introduce nested quote problems.