This post was originally published on my blog, find original post here
For server-side environment, you can execute the script with command like
santhosh@ubuntu-18-04:~$ node script.js
<!DOCTYPE html> <html lang="en"> <head> </head> <body> <script> alert("Hello World"); </script> </body> </html>
alert is browser specific function.
script tag contains scripts which will be automatically executed when browser loads this webpage.
script tag contains few attributes.
It is not required to specify the type in HTML5, usually it was
In old standard HTML4, it is required to put type of the script
only the simplest scripts are put into HTML. More complex ones reside in separate files.
Script files are attached to HTML with
we can attach third party script as well.
we can attach many scripts as much as we want.
<script src="/path/to/script1.js"></script> <script src="/path/to/script2.js"></script> <script src="/path/to/script3.js"></script> <script src="/path/to/script4.js"></script>
If a script element has a src attribute specified, it should not have a script embedded inside its tags.
alert statement will not run.
<script src="/path/to/script4.js"> alert("this will not run"); </script>
Top comments (0)