Forum Moderators: open

Message Too Old, No Replies

JavaScript Language Attribute

What happens if...

         

pageoneresults

4:06 pm on Jan 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



For those of you validating your documents, you've most likely run into the javascript language attribute error. The language attribute has been deprecated. But, what happens if you don't use it? Why do programmers/developers continue to use this...

<script type="text/javascript" language="javascript" src=""></script>

When this is the correct way and has been for quite some time.

<script type="text/javascript" src=""></script>

I'm not a javascript person and really don't know what adverse effects there would be in removing that language attribute from all javascript references.

Is there a backwards compatibility issue? In this day and age? Anyone?

pageoneresults

1:17 pm on Jan 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



A shameless bump!

Could I assume that no one knows the answer to this one? No one? Come on, this is WebmasterWorld!

txbakers

1:23 pm on Jan 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Shameless reply!

I really don't know the answer to that one. I was one of those that used both for a while, then just stopped using "language" in there going forward and I haven't had any issues.

I also stopped commenting out the javascript long ago without any adverse affects.

I'm thinking this might get an answer in the JavaScript forum - should we move it there?

Fotiman

3:05 pm on Jan 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The language attribute can safely be removed. JavaScript (or ECMAScript) has always been the default scripting language for all browsers that support scripting, so you're not breaking any backwards compatibility by removing it.

I suspect that the only reason developers continue to use it is because they just don't know any better. In fact, I see a lot of this:

<script language="JavaScript">

In other words, not including the type attribute. Again, I think it's just they learned it way back in the day when there was talk of multiple languages being supported, and so they continue to do it that way.

Here's another thing that can be dropped:

<script type="text/javascript">
<!--

// -->
</script>

The html comments were a hack to work with Mosaic and Navigator 1.0. They have not been required for many, many years. Unless you think you need to support those ancient browsers, there's no need to continue writing script like this. And if you do think you need to support those old browsers, you should get your head checked. ;-)

StupidScript

10:10 pm on Jan 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It continues to amuse me how Dreamweaver and others still use language="Javascript" and no type attribute. (Not to mention the hideous script structures) I guess it's one of those things that don't get much thought in certain circles.

pageoneresults

10:26 pm on Jan 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Whew! I just wanted to make sure I wasn't breaking anything.

Can anyone tell me why the WebTrends code has 6 different javascript references? They go from 1.0 to 1.5. Nothing like covering your butt from all directions, eh?

<script type="text/javascript" language="javascript 1.0">
<!--
gVersion="1.0";
//-->
</script>
<script type="text/javascript" language="javascript 1.1>
<!--
gVersion="1.1";
//-->
</script>
<script type="text/javascript" language="javascript 1.2>
<!--
gVersion="1.2";
var RE={"%09":/\t/g, "%20":/ /g, "%23":/\#/g,"%26":/\&/g,"%2B":/\+/g,"%3F":/\?/g,"%5C":/\\/g};
//-->
</script>
<script type="text/javascript" language="javascript 1.3>
<!--
gVersion="1.3";
//-->
</script>
<script type="text/javascript" language="javascript 1.4>
<!--
gVersion="1.4";
//-->
</script>
<script type="text/javascript" language="javascript 1.5>
<!--
gVersion="1.5";
//-->
</script>

StupidScript

11:59 pm on Jan 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



More than likely it is due to the way WebTrends handles things like arrays and date objects, which are among the most-frequently modified items in the language. For example, Javascript v.1.3 added the getFullYear function, so browsers that are incapable of recognizing v.1.3 would need a different constructor for functions that use getFullYear.

It does seem like quite a bit of overkill, however. I mean ... c'mon WebTrends ... use some server-side code to obviate the need for such particlization, why dontcha?