homepage Welcome to WebmasterWorld Guest from 54.224.202.109
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
The Script Element
Language Attribute is deprecated!
pageoneresults




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

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




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

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...]

pageoneresults




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

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. :(

DrDoc




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

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. :)

pageoneresults




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

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?

rocknbil




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

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. :-)

DrDoc




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

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

Bernard Marx




msg:1482683
 8:39 pm on Feb 14, 2006 (gmt 0)

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.

DrDoc




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

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved