In previous toast we write our first Script. We place the script in body element. It would also work in these ways:

 

Placing Script element in head

<head>
<meta charset="UTF-8">
<title>Script in Head</title>
<script>
alert("web Toasts are awesome");
</script>
</head>

 

Placing Script element in the start of body

 

<body>
<script>
var toast;
toast=3;
alert(toast);
</script>
<h1>Script in the start of body</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Debitis quaerat vel, ducimus qui ex dignissimos a incidunt consectetur beatae saepe accusantium veritatis quos nisi assumenda dolorem dolores amet alias ad!</p>
</body>

 

Placing Script element in the end of body

 

<body>
<h1>Script in the start of body</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Debitis quaerat vel, ducimus qui ex dignissimos a incidunt consectetur beatae saepe accusantium veritatis quos nisi assumenda dolorem dolores amet alias ad!</p>
<script>
var toast;
toast=3;
alert(toast);
</script>
</body>

 

What is the best option for placing SCRIPT element? Well it depends, but most of the times we should write the SCRIPT in the last of the body element so that we make sure that all the other content is loaded before the script is being interpreted.