By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,264 Members | 1,743 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,264 IT Pros & Developers. It's quick & easy.

difference between "text/javascript" and "JavaScript"

P: n/a
Hi

I am new to Javascript and am not sure what is the difference between the
following two statements:

<script type="text/javascript">
.....
</script>
and
<SCRIPT LANGUAGE = "JavaScript">
<!--
.....
</SCRIPT>

Can someone elaborate on this? Thanks
Apr 18 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Navodit said the following on 4/18/2007 12:11 PM:
Hi

I am new to Javascript and am not sure what is the difference between the
following two statements:
The first is required by the validator, the second is deprecated by the
validator (although both are deprecated).
<script type="text/javascript">
....
</script>
and
<SCRIPT LANGUAGE = "JavaScript">
<!--
....
</SCRIPT>

Can someone elaborate on this? Thanks
Aside from the validator barfing on that language attribute, there are
some versions of the language attribute (javascript1.2 is the most
prevelant) can cause some unexpected behavior in some browsers.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 18 '07 #2

P: n/a
dd
On Apr 18, 6:11 pm, "Navodit" <kaush...@uiuc.eduwrote:
I am new to Javascript and am not sure what is the difference between the
following two statements:
<script type="text/javascript">
and
<SCRIPT LANGUAGE = "JavaScript">
Can someone elaborate on this? Thanks
The language="javascript" is the oldest syntax and is supported
by all browsers, even the newest. The <script part tells the HTML
parser what it's about to receive, and the language parts tells it
that the script is in javascript format.

The type="text/javascript" came along later and was meant to be
the preferred new method of declaring javascript. This relates to
mimetype and instructs the browser that it's plain text and the
language is javascript. I imagine the idea was that you might be
able to have compressed text also e.g., "compressed/javascript"
but that never came into existence. This is just speculation here.

When text/javascript came along they did something that has
been mostly used by the Java community, which is to "deprecate"
the old style language tag.

That means simply that they don't recommend using that in any
new code, and when time permits (or next time you're working on
it) update any old code. There's never been any timetable on
when language="javascript" would no longer be supported, and
as it's used so widely across the internet, nobody wants to break
lots of webpages that sit out there unmodified and will do so for
years to come. So NO NEW browsers have ceased supporting the
language tag and I doubt without any other major sweeping change
in the web occurring, it will become unsupported.

All my code releases continue to use language="javascript" and
will continue to until a new browser comes along that doesn't like it.
I don't see the benefit of changing my code and suddenly alienating
any older browsers that maybe don't know about it. It ain't broke so
I'm not going to try fixing it :)

Apr 19 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.