A+ A-

How does inline Javascript (in HTML) work?

Definition of In-Line Javascript

To define a Javascript block in your web page, simply use the following block of HTML.

[code type="JavaScript"]



[/code]

You can place these script blocks anywhere on the page that you wish, there are some rules and
conventions however.

If you are generating dynamic content as the page loads you will want the
script blocks to appear where you want their output to be. For instance, if I wanted to say "Hello World!" I would want my script block to appear in the <body> area of my web page and not in the <head> section.

Unless your scripts are generating output as the page loads, good practice says that you should
place your scripts at the very bottom of your HTML. The reason for this is that each time the
browser encounters a <script> tag it has to pause, compile the script, execute the script, then
continue on generating the page. This takes time so if you can get away with it, make sure the
browser hits your scripts at the end of the page instead of the start.

You can place these script blocks anywhere on the page that you wish, there are some rules and conventions however. js, java script, javascript tutorial, javascript replace, learn javascript,javas, javascript