History of the JavaScript script Tag
History of the JavaScript script Tag
in the beginning, around 1997, it is this:
<script language="JavaScript">...</script>
The idea was, we can support other programing languages in the future.
Then, around maybe year 2000, the standard body W3C says it should be this:
type="text/javascript"
The idea was, this is more general form, to support any type of object, not just programing languages.
Then, around 2006-04, the standard body W3C says it should be this:
type="application/javascript"
The idea was, this is more correct. JavaScript is considered an application, not text.
Then, around 2010, HTML5, the standard body, now WHATWG running the show, says it should be just:
<script>...</script>
The idea was, there is no other web scripting languages in practice, and all those text or application declaration are in practice ignored by browser.
History: HTML Script Tag Survey, Year 2006
the following is written around 2006.
In practice, you'll see
type="text/javascript"
instead of
type="application/javascript"
The text/javascript
is still ok, but has been deprecated since 2006-04.
Of existing code on the web, you will also see:
<script language="JavaScript">...</script>
or just
<script>...</script>
The language=
is the original specification when Netscape invented JavaScript in 1997.
Later on, standard bodies invented the type=
and made it a required attribute.
However, as of 2005-08, major websites do not clearly show any of them
winning the popularity contest:
- amazon.com uses both
type=
andlanguage=
and sometimes just thelanguage=
. - apple.com uses just the
language=
. - yahoo.com uses just the
language=
. - orkut.com uses just the
type=
. - msn.com sometimes uses both, sometimes one or the other.
- ebay.com sometimes uses both, sometimes one or the other.
- google.com simply uses just
<script>
For all practical purposes, one can just use
<script>
and it doesn't make any difference. If you want your code to conform to w3c standard, use
<script type="application/javascript">
. This is recommended in RFC4329 (published in 2006-04), which also declares
text/javascript
as obsolete.