Welcome to WebmasterWorld Guest from 54.147.212.98

Forum Moderators: open

Message Too Old, No Replies

The Script Element

Language Attribute is deprecated!

   
6:09 pm on Feb 11, 2006 (gmt 0)

WebmasterWorld Senior Member pageoneresults is a WebmasterWorld Top Contributor of All Time 10+ Year Member



18.2.1 The SCRIPT element [w3.org]

Why is it that developers of Scripts continue to use the deprecated...

<script language="javascript">

...when the correct element to use is...

<script type="text/javascript">

Am I missing something? If I'm not, why do developers continue to use the deprecated language tag? I'm finding it in many statistical programs, free scripts, etc.

language = cdata [CI]
Deprecated.
This attribute specifies the scripting language of the contents of this element. Its value is an identifier for the language, but since these identifiers are not standard, this attribute has been deprecated in favor of type.

gph

6:47 pm on Feb 11, 2006 (gmt 0)

10+ Year Member



I think different reasons. Some because they don't know it's depreciated. Some know but if it's not broken, don't fix it. Others might be keeping IE happy, see Remarks:

[msdn.microsoft.com...]

1:46 am on Feb 13, 2006 (gmt 0)

WebmasterWorld Senior Member pageoneresults is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Others might be keeping IE happy, see Remarks:

Thanks gph, I've read that before and it raises questions.

Whenever the language attribute is not defined on the SCRIPT object, then MSHTML attempts to select a suitable scripting engine. An error generally occurs if the wrong scripting engine is selected.

Scripting is not my forte. But, how often would the wrong scripting engine be selected? And, why would the W3C mark the attribute as deprecated?

When more than one SCRIPT object is used on a page, it can be necessary to specify the language attribute for each SCRIPT object, and doing so is always recommended.

Okay, so MS are recommending that I utilize deprecated markup for instances where more than one SCRIPT object is used. That just doesn't seem right to me. I've been stripping away those language attributes for years and can say that I've never seen any adverse effects.

Is this something you can shed a little more light on? I mean, if the attribute is deprecated, what purpose is it serving? I've read the MS Remarks numerous times and I just can't get it to sink in. :(

2:08 am on Feb 13, 2006 (gmt 0)

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member



I have never ever had any problems with IE picking the wrong language.
I have not used the language attribute for years.

The only problem you might run into is if you are using a non-JavaScript script (such as VBScript or proprietary JScript [or XML, as in the {stupid} example]). But then again, those do not work properly in other browsers, so you can successfully avoid both error messages and validation problems by throwing the entire script into a conditional comment. Problem solved. :)

2:10 am on Feb 13, 2006 (gmt 0)

WebmasterWorld Senior Member pageoneresults is a WebmasterWorld Top Contributor of All Time 10+ Year Member



I have never ever had any problems with IE picking the wrong language.

Are the differences in the languages that different? I mean, I've seen 1.1, 1.2, 1.3, 1.4, etc. No need to get into detail but, what's the major difference between the language versions? And why would I want to use one as opposed to the other?

7:22 pm on Feb 14, 2006 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Each successive version adds functionality and tools, like anything else. For example, I don't believe regexps were available in some of the earlier versions (?). Back in the day, some browser support was only limited to say, 1.1, so if you were using some of the new widgets from 1.2 an specifically set the language version, it would act as if Javascript was disabled and ignore the entire block. If you left off the version, it would run but throw an error, something to the effect of "null or not an object" when it tried to refer to some of the methods in the newer versions.

As to why the language=, many people are forced into learning Javascript only because they've ripped a functional script from a free site and began tweaking it to suit their needs. Like all bad habits, it sticks, and most of these people either truly don't have the time or aren't inclined to seek out the "right" way to do it, if it works, it works. :-)

7:38 pm on Feb 14, 2006 (gmt 0)

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member



The only time you would run into a problem with functionality in older browsers is if you are trying to cater to IE3/4 or NN4
8:39 pm on Feb 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



rocknbil: As to why the language=, many people are forced into learning Javascript only because they've ripped a functional script from a free site and began tweaking it to suit their needs.

That's probably true, but I think it's also fair to say that many major sites haven't updated their Javascript tutorials & examples since they were established back in the 90's (incl. MS). These sites still feature prominently in the SERPs for newbie-type Javascript searches.

This is why most newcomers appear unaware of literal notation for Objects and Arrays, and of the array methods that MS added (belatedly) in IE5.5. It's also why we still get people using eval all over the place (and that was never necessary anyway!).

Re: specifying language version

Using values like "javascript1.n" is meaningless in most people's browsers anyway, since the ubiquitous IE actually runs JScript, which uses a different versioning system.

9:07 pm on Feb 14, 2006 (gmt 0)

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member



IE does, however, do some form of internal conversion between JScript and JavaScript.