homepage Welcome to WebmasterWorld Guest from 184.73.104.82
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

    
Proper linking for external JavaScript files
language is out; type is in
tedster

WebmasterWorld Senior Member tedster us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 633 posted 4:02 am on Jun 18, 2001 (gmt 0)

Apparently this change happened a while back, but I didn't catch it until recently, when I ran a few problem pages through the W3C validator.

When linking to an external .js file, I always used the attribute language="JavaScript" in the script tag. This doesn't validate. The proper attribute is type="text/javascript".

There are sources all over the web that still recommend the language attribute, so I'm not rushing to correct all my sites just now, but seems like that job must be done some day.

(edited by: tedster on 9:20 am (gmt) on June 18, 2001)

 

chiyo

WebmasterWorld Senior Member chiyo us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 633 posted 4:38 am on Jun 18, 2001 (gmt 0)

Thanks Tedster. great advice.. We tend to use public domain js initially and adapt/extend them over the years. and yes hadn't notice that there was 2 ways of referring to js scripts in our code.

Xoc

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 633 posted 6:03 am on Jun 18, 2001 (gmt 0)

You should use both attributes. The language attribute is deprecated. The type attribute is the new one. Old browsers don't support the type attribute. A strict html 4.0, or xhtml 1.x page won't validate with the language attribute, but no browser really can do strict html since support for cascading style sheets is so bad.

<edit>Fixed wording</edit>

(edited by: Xoc at 4:17 pm (gmt) on July 14, 2001)

Rumbas

WebmasterWorld Administrator 10+ Year Member



 
Msg#: 633 posted 8:15 am on Jun 18, 2001 (gmt 0)

Could you clarify this - I'm a bit slow ;)

This is the linking I've always used:

<script language=JavaScript src="file.js"></script>

Change that to:

<script type="text/javascript" src="file.js"></script>

tedster

WebmasterWorld Senior Member tedster us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 633 posted 9:19 am on Jun 18, 2001 (gmt 0)

To accommodate old and current browsers, we should be using:

<script type="text/javascript" language="JavaScript" src="file.js"></script>

Thanks, Xoc.

Rumbas

WebmasterWorld Administrator 10+ Year Member



 
Msg#: 633 posted 1:13 pm on Jun 18, 2001 (gmt 0)

Thanks guys :)

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