Inline vs External JavaScript

Sharing is Caring

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.

Author: Brian Cline

Brian is a programmer living in Niagara Falls with ten years of development experience. He is passionate about automation, business process re-engineering, and gamification. For the last six years or so, he has been working with Salesforce and JavaScript.

Related Posts

Sharing is Caring

Comments are closed.