What is JavaScript?
JavaScript is a programming language that adds interactivity to web sites. It is a client-side scripting language, which means that runs in the user's browser and not on the web server.
JavaScript is both lightweight and dynamic. Unlike many other scripting languages, JS doesn't need to first be run through any form of compiler that interprets our human-readable code into something the browser understands. The browser is able to read the code that we type and interpret it on the fly.
JavaScript is among the most important programming languages for website owners who want to make their site more interactive, which makes it the most complex of the three web languages of HTML, CSS, and JavaScript. While HTML provides the structure for a website and CSS allows you to control the presentation of a site, JavaScript gives you tools to change the behavior of elements and add interactivity on your pages that can't be done with HTML or CSS.
How do you add JavaScript to your page?
You add JavaScript to your page using the <script> element. Just like CSS, it can be embedded within the page itself or connected via an external file.
The preferred method is to use the src= attribute to point to an external .js JavaScript file.
<script src="example.js"> </script>