Forum Moderators: open
A. <script type="text/javascript">
B. <script language="JavaScript">
C. <script language="JavaScript1.2">
I also see a lot of scripts no longer use the
<!--
and
// -->
is this ok, or do they really need to be there?
Next, what are the pros and cons of putting the script IN the HTML vs. calling the script via an "include" OR like this:
<script language="JavaScript1.2" src="animate.js">
When answering, please keep in mind I'm dealing with plain HTML, not with the "x" ;-)
Thanks!
Shadows Papa
<!--
and
// --> Hides the script from old browsers, which would simply print the coding of the script without them.
If the script is to be used on more than one page it is better to call the script externally. Most browsers will cache the script on the first pageview. Saves some downloading time for the user and also helps push the real content of the page up higher in the document.
Regards,
Birdman
First of all, keep in mind that these are HTML comments. When we say that they were used as a trick to hide JavaScript from "old" browsers -- we're talking really old! You really don't have to use them anymore...
Now, to take it one step further... If you're designing XML or XHTML pages -- you shouldn't use HTML style comments in your CSS/JavaScript. Why? Because XML based rendering engines are allowed to silently remove the contents of comments. This would, of course, cause your JavaScript/CSS not to work...