Of course, the HTML parser will not accept any commands in the SCRIPT language.
— Tim Berners-Lee
1991
Today JavaScript is the lingua franca of the web, and it’s used on essentially every website. Its use is so pervasive many websites don’t even render without JavaScript enabled, a fact often bemoaned by Hacker News readers who chose to use script blocking browser extensions.
It wasn’t always so clear however. Historically there have been attempts to allow browsers to support a wide variety of languages.
VBScript
The Visual Basic language
vbscript
was supported by Internet Explorer up
through IE10, and can still be used in IE11 with the IE10 emulation mode
enabled. VBScript is notable for being the language you would program in if
you ‘hacked’ into Microsoft Excel on a computer at your high school.
Borrowing an example from the MSDN, VBScript on a webpage would look something like this:
<script language="VBScript">
Sub Button1_OnClick
Dim TheForm
Set TheForm = Document.forms("ValidForm")
If IsNumeric(TheForm.Text1.Value) Then
If TheForm.Text1.Value < 1 Or TheForm.Text1.Value > 10 Then
MsgBox "Please enter a number between 1 and 10."
Else
MsgBox "Thank you."
TheForm.Submit
End If
Else
MsgBox "Please enter a numeric value."
End If
End Sub
</script>
tcl
The HTML 4.01 spec
famously includes a reference to text/tcl
, or the tcl programming
language. There have been many attempts to
get tcl into browsers over the years, including an ActivX plugin, NaCl
extension and even a patch to the Mozilla browser. The message board
post
discussing it in 1998 somewhat tragically ends with “Do you think there’s any
hope for making Tcl a mass-market browser scripting language?”. :.(
An example of tcl from the HTML spec looks like this:
<script type="text/tcl">
proc edit1_changed {} {
if {[edit value] == abc} {
button1 enable 1
} else {
button1 enable 0
}
}
edit1 onChange edit1_changed
</script>
Rexx
Everyone’s favorite browser, IBM WebExplorer included support for Rexx, an OS/2 scripting language which is a half step above Bash scripting. PC Mag described WebExplorer as “lack[ing] [in] several standard features” and not “very strong in terms of multimedia support”, so it’s unlikely its popularity will grow in the future.
Python
Python was the hot scripting language of the day in 1995 when much of the original client-side scripting work was done, leading to the obvious thought that it would be the best choice for inclusion in the browser. Apparently Python was at one point embedded in the Mosaic browser, and there was work to make it executable in Firefox, but it was discontinued when JavaScript became the clear winner.
Today
These days, with all the investment in ES6 and precompilers, it seems pretty unlikely that another scripting language will take off on the web. Or as a Mozilla maintainer described it in 2012: “JS is ubiquitous on the web, and that’s not going to change anytime soon, so there’s no point in carrying the baggage necessary for multiple scripting engines that never materialized.”
There is however an effort to make it possible to compile virtually every language into JavaScript to make it executable in the browser. Firefox, Chrome and IE Edge all support asm.js which is a subset of the JavaScript syntax which can be very quickly executed. It is designed to make it possible to translate code in compiled languages like C to run on the web.
Our next post will cover everything I know about the script tag, and will hopefully be more interesting than it sounds. Subscribe below to find out!