DEV Community

stalin s
stalin s

Posted on

JavaScript linking your javascript file

JavaScript file ends with a .js. These files are then stored in a js Folder that's located at the same level of your HTML for easy indication.

attached folder structure below [for clear visualization]
Like this
Image description

Now let's get into main topic for our discussion.

   ** Linking your JavaScript file to your HTML file**
Enter fullscreen mode Exit fullscreen mode

For JavaScript files to work , we need to link them you HTML file - > This can be done by adding script tag at the bottom of the html document before closing the body tag or inside inside head section

<html>
<head>
<meta charset="utf-8" />
<title>Title website </title>
</head>
<body>
<!-- Please enter js script inside -->
<script src="js/index.js"></script>
</body>
</html>

In index.js file ,Let's enter alert('Javascript file linked').

If we try to open the index.html , the browser will display a pop that says "Javascirpt file linked".

Attaching image below.
Image description

Happy learningđŸ’—

Top comments (0)