What are the ways of adding JavaScript code in an HTML file?

There are primarily two ways of embedding JavaScript code:

  • We can write JavaScript code within the script tag in the same HTML file; this is suitable when we need just a few lines of scripting within a web page.
  • We can import a JavaScript source file into an HTML document; this adds all scripting capabilities to a web page without cluttering the code.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *