Script Tag in JavaScript

 <!DOCTYPE html>

<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Title 24</title>
    <link rel="stylesheet" href="style.css" type="text/css">
</head>

<body>
    Hello World
    <!-- Advantages of using separate script file using src attribute of script tag
        1. Separation of concerns
        2. Browser Caching -->
    <script src="script.js">
        console.log("I am trying to be smart"); //This will be ignored
    </script>
</body>

</html>







script.js File
console.log("Hello");
let a = 4;
let b = 2;
console.log(a + b);







style.css File
html, body {
    background-color: red;
    color: white;
    height: 100%;
    width: 100%;
}



Comments

Popular posts from this blog

Generators tutorial in Advance JavaScript

Document Object Module DOM querySelector and querySelectorAll tutorial in JavaScript

Find Even and Odd Numbers with Loops tutorial in JavaScript