Category: JavaScript

Placement of Script Tag in HTML File

It is a very common question where you should place your script tag.  Few people prefer placing it after head tag and few prefer placing it somewhere in the body tag.  If there is no manipulation of HTML elements on page load, then it is okay to place it in the head tag.  But if

External JavaScript Code

External JavaScript code is placed inside an external JavaScript file.  This external JavaScript file contains a lengthy JavaScript code.  If you place same lengthy code inside a HTML file, it will make your whole code file look ugly.  It’s a good habit to place all lengthy code inside an external JavaScript file and add path

Inline JavaScript Code

Any JavaScript code, which is placed directly within a HTML file, is called Inline JavaScript code.  Inline JavaScript code should not be lengthy.  It should be a little piece of JavaScript code.  Example of Inline JavaScript code is given below. <html> <head> <title>JavaScript Tutorial </title> </head> <body> <script type="text/javascript"> alert("Hello World"); </script> </body> </html>  

Disadvantages of Using JavaScript

As we know, JavaScript is extremely helpful in case of manipulating DOM of a web page.  JavaScript can be used in a good way or bad way.  There are 3 main disadvantages of using JavaScript. Disabling Option:  Almost all the browsers have an option in settings to disable JavaScript. This means if someone has disabled