Forum Moderators: open
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.
[msdn.microsoft.com...]
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. :(
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. :)
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?
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. :-)
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.