Sustainability of Digital Formats: Planning for Library of Congress Collections

Introduction | Sustainability Factors | Content Categories | Format Descriptions | Contact
Format Description Categories >> Browse Alphabetical List

ECMAScript Language (ECMA-262), including JavaScript

>> Back
Table of Contents
Format Description Properties Explanation of format description terms

Identification and description Explanation of format description terms

Full name ECMA-262: ECMAScript Language Specification. [Formerly also published as ISO/IEC 16262.] Often referred to as JavaScript, the most well known implementation of the ECMAScript language.
Description

ECMAScript is a programming language, developed and maintained as an international standard under the auspices of the Technical Committee (TC) 39 of Ecma International and published openly as ECMA-262 (ECMAScript Language Specification) in a series of editions, beginning in June 1997. [Note: Ecma International was formerly the European Computer Manufacturers Association and known by its acronym, ECMA; names for ECMA standards continue to use the upper-case form.] Technically identical specifications for ECMAScript were published as ISO/IEC 16262 in 1998, 2002, and 2011. To facilitate an annual update cycle for the language, ISO/IEC 22275 (ECMAScript Specification Suite) was published in 2018 to incorporate updated editions of ECMA-262 by reference.

Given the complex but extremely close relationship between ECMAScript and JavaScript, the compilers of this resource have chosen to produce a single format description that covers both. To describe the current relationship as briefly as possible, ECMAScript is the formal standard on which JavaScript is based, while JavaScript is often described as an implementation or a dialect of ECMAScript. Comments welcome.

The language now standardized as ECMAScript was invented by Brendan Eich at Netscape Communications Corporation to support cross-platform scripting. It first appeared in that company's Navigator 2.0 browser, released in 1995. After trying some preliminary names, Netscape chose the name JavaScript for the language. See the December 1995 press release from Netscape and Sun Microsystems announcing JavaScript as an "open, cross-platform object scripting language for the creation and customization of applications on enterprise networks and the Internet." At that point, the plan was to offer the language to W3C (World Wide Web Consortium) and IETF (Internet Engineering Task Force) as an "an open Internet scripting language standard." In mid-1996, Microsoft introduced an equivalent in Internet Explorer 3.0, using the name JScript. In a November 1996 press release, Netscape announced that it had submitted JavaScript to Ecma International for consideration as an industry standard. To produce the standard, Ecma formed TC39. Ecma's Memento yearbook for 1997 lists members of TC39 representing Sun Microsystems, Netscape, Microsoft Corporation, Apple, IBM, Hewlett Packard, Digital Equipment Corporation, and more. The name "ECMAScript" was chosen as a compromise with no association with any particular company. The ECMAScript Language Specification was adopted by the Ecma General Assembly as ECMA-262 in June 1997. The language drew from JavaScript, but also on other sources, including JScript from Microsoft. JavaScript and JScript are now considered dialects of the ECMAScript language and implementations of the ECMAScript standard. Of these dialects, JavaScript remains the most well known and in many contexts the term "JavaScript" is used where "ECMAScript" might be more appropriate but would not be immediately recognized. For example, the tutorial A re-introduction to JavaScript has a note, "Because it is more familiar, we will refer to ECMAScript as 'JavaScript' from this point on."

In 2016, Ecma TC39 began to publish a new edition of ECMA-262 every year on a schedule, as the large working group, including representatives from all major browser vendors and many media companies and internet platforms, develops consensus on added features. Each annual release of ECMA-262 includes any new features that have been approved using the five-stage TC39 Process. For a feature to reach the "finished" stage, ready for inclusion in ECMA-262, it must be included in implementations that have been shipped and at least two compatible implementations must have passed acceptance tests established by TC39. These new editions are often referred to by year, sometimes as ES2016, ES2017, etc. See for example, The Complete ECMAScript 2015-2017 Guide and ECMAScript compatibility table (ES2016+). For additional discussion on the relationship between ECMAScript and JavaScript, see Notes and Useful References below.

An Overview of the ECMAScript language is provided in the standard and includes an important statement, emphasized in bold in the following extract:

  • "ECMAScript is an object-oriented programming language for performing computations and manipulating computational objects within a host environment. ECMAScript as defined here is not intended to be computationally self-sufficient; indeed, there are no provisions in this specification for input of external data or output of computed results. Instead, it is expected that the computational environment of an ECMAScript program will provide not only the objects and other facilities described in this specification but also certain environment-specific objects, whose description and behaviour are beyond the scope of this specification except to indicate that they may provide certain properties that can be accessed and certain functions that can be called from an ECMAScript program."

Other points from the Overview in the ECMAScript specification are worth mentioning. ECMAScript, like its predecessor JavaScript, was originally designed to be used as a scripting language for the Web, providing a mechanism "to enliven Web pages in browsers and to perform server computation as part of a web-based client-server architecture." ECMAScript syntax intentionally resembles Java syntax but in a relaxed form to enable it to serve as an easy-to-use scripting language. Each web browser and server that supports ECMAScript must supply its own "host environment." For example, a browser provides an ECMAScript host environment for client-side computation including, for instance, objects that represent windows, menus, pop-ups, dialog boxes, text areas, anchors, frames, history, cookies, and input/output. A web server must provide a complementary host environment for server-side computation including objects representing requests, clients, files, and mechanisms to lock and share data. For an informative overview of JavaScript support and the host environment in Firefox (from Mozilla), see JavaScript technologies overview: Introduction. Firefox has implemented support in a JavaScript engine known as SpiderMonkey and a "layout engine" known as Gecko. Other browsers have developed their own JavaScript engines, e.g., V8 used by Chrome and other Google products.

ECMAScript has evolved to support scripting capabilities in a variety of contexts, including:

JavaScript is a programming language with some special characteristics. The formal specification found in ECMA-262 is not easy to read but there are a number of useful introductions, tutorials, and reference materials for JavaScript available online, including MDN (formerly the Mozilla Developer Network) and w3schools.com. Some people suggest that JavaScript is only a scripting language and not a programming language at all, but as of 2019, the consensus is that it is both; see, for example Is JavaScript a programming language? from Quora. Among the special characteristics are:

  • According to What is JavaScript?, a tutorial from MDN, "JavaScript is a scripting or programming language that allows you to implement complex things on web pages." Later in the same tutorial is the more technical description, "JavaScript is a lightweight interpreted programming language. The web browser receives the JavaScript code in its original text form and runs the script from that. From a technical standpoint, most modern JavaScript interpreters actually use a technique called just-in-time compiling to improve performance; the JavaScript source code gets compiled into a faster, binary, format while the script is being used, so that it can be run as quickly as possible. However, JavaScript is still considered an interpreted language, since the compilation is being handled at run time, rather than ahead of time."
  • Unlike programming languages such as C and Java, JavaScript has no main program that controls program flow. Execution of a chunk of JavaScript code, a script, is triggered by an event. In web pages, events are often actions taken by a user, perhaps by clicking on a button or tab. See Concurrency model and the event loop from MDN.
  • JavaScript allows developers to use alternative programming approaches, procedural programming and functional programming. See Functional vs Procedural JavaScript. Although JavaScript is object-oriented, it does not feature classes, which are an important part of most object-oriented languages, controlling inheritance. Instead, it uses a mechanism based on so-called prototypes to support inheritance. See, for example, Introduction to Object Oriented Programming in JavaScript and JavaScript Reference: Classes from MDN. The latter states, "JavaScript classes, introduced in ECMAScript 2015, are primarily syntactical sugar over JavaScript's existing prototype-based inheritance. The class syntax does not introduce a new object-oriented inheritance model to JavaScript."

Importantly, the ECMAScript specification has an annex (Annex B: Additional ECMAScript Features for Web Browsers) that lists legacy features. The purpose of the annex is to describe "various legacy features and other characteristics of web browser based ECMAScript implementations. All of the language features and behaviours specified in this annex have one or more undesirable characteristics and in the absence of legacy usage would be removed from this specification. However, the usage of these features by large numbers of existing web pages means that web browsers must continue to support them. The specifications in this annex define the requirements for interoperable implementations of these legacy features." A guiding principle for TC39 is “Don’t Break the Web”. See A Year (plus a little) on TC39 (January 2019) by Aki Rose.

Relationship to other formats
    Used by HTML_family, HyperText Markup Language (HTML) Format Family
    Used by PDF_family, Portable Document Format (PDF) Family. See JavaScript for Acrobat.

Local use Explanation of format description terms

LC experience or existing holdings The Library of Congress acquires files in scripting languages, including ECMAScript variants (primarily JavaScript), associated with documents in HTML collected through its Web Archiving program. See Library of Congress Web Archiving.
LC preference The Library of Congress collects scripting files and embedded ECMAScript code only as supplementary to other content, such as documents in HTML or PDF formats. No preference is expressed for such supplementary resources in its Recommended Formats Statement.

Sustainability factors Explanation of format description terms

Disclosure An openly published international standard, developed under the auspices of Ecma Technical Committee (TC) 39. The first edition of the ECMAScript standard (ECMA-262) was adopted by the Ecma International General Assembly in June 1997. Since 2015, when the 6th edition was published, TC39 has published a new edition each year, using a multi-stage process to guide the evolution of the language. A working draft and proposals for new features are publicly available.
    Documentation

The latest published version of the ECMAScript Language Specification can be found as ECMA-262. Earlier versions are available from https://www.ecma-international.org/publications/standards/Ecma-262-arch.htm. A working draft for the next version is available at https://tc39.es/ecma262/.

For versions published as ISO/IEC 16262, see Format Specifications below.

Adoption

The ECMAScript Language has been adopted in a number of application contexts. The most well known context is in web pages and the web servers that deliver those pages. Implementations in this context are usually referred to as JavaScript. According to The Baseline Interpreter: a faster JS interpreter in Firefox 70, an August 2019 blog post from Mozilla, "Modern web applications load and execute a lot more JavaScript code than they did just a few years ago." In addition to direct use of JavaScript by web developers, tools have emerged to facilitate its use. For example, in 2005, the term Ajax, standing for Asynchronous JavaScript + XML, a technical approach developed by Google for use in applications like Gmail and Google Maps. See the 2005 article, Ajax: A New Approach to Web Applications by Jesse James Garrett. Popular JavaScript code libraries that support straightforward interactivity and are packaged with some website development platforms include jQuery (first released in 2006) and Bootstrap (first released in 2011). Several frameworks for building websites that make heavier use of JavaScript have emerged, including AngularJS in 2009, Backbone.js in 2010, Ember.js in 2011, and React.js in 2013.

JavaScript is used to some degree in a very large percentage of websites. A W3Techs survey from August 2010 found that 88.2% of the top 1 million sites as ranked by Alexa used JavaScript somewhere on the website. The equivalent W3Techs survey in July 2019 found that 95.2% of the top 10 million sites used JavaScript. This statistic does not capture how heavily a site exploits scripting; a single contact form using JavaScript would lead to a website being counted. The W3Techs survey of usage of JavaScript libraries shows the popularity of the JavaScript libraries: jQuery (used in 74.0% of websites in July 2019) and Bootstrap (19.2% in July 2019).

Browsers incorporate JavaScript/ECMAScript "engines" to interpret and execute JavaScript code. For example, Firefox uses SpiderMonkey and Chrome uses V8. See Wikipedia's List of ECMAScript engines for more examples. Support for individual ECMAScript features by various browsers and engines is documented in Kangax Compatibility Tables for ES6 (i.e., ES2015) and Kangax Compatibility Tables for ES2016+ (i.e., for versions of ECMA-262 published since 2016).

Although the major browsers steadily introduce versions that support the features introduced in the new versions of ECMA-262, web developers have to design on the assumption that many users will be using older browsers. A number of tools and techniques have been developed to allow developers to take advantage of new features as they design, but supplement or modify the JavaScript to allow use in older browsers. Two important tools are known as polyfills and transpilers. Babel JS is a popular toolkit that is mainly used to convert code in ECMAScript from 2015 and later into a backwards-compatible version of JavaScript that will work in current and older browsers or environments. Babel JS incorporates a transpiler, translating modern JavaScript code into a previous standard and integrates polyfills that will implement new features missing from the older standard. As of 2019, Babel uses polyfills derived from core.js, a library of polyfills. Another source for polyfills is polyfill.io, a service developed by the Financial Times that can supply polyfills tailored to a browser over the network when a page is loaded.

Node.js is a widely used open-source, cross-platform, JavaScript runtime environment, built on Chrome's V8 JavaScript engine, that executes JavaScript code in contexts other than browsers. For example, Node.js facilitates use of JavaScript for command line tools and server-side scripting. The support in Node.js for individual features in ES2015 and later versions of ECMA-262 is documented in https://node.green/.

Examples of adoption of ECMAScript in non-browser contexts include: ECMAScript for PDF; ECMAScript for XML (E4X); JScript for .NET; in embedded systems (in the Internet Of Things) [see TC53 - ECMAScript Modules for Embedded Systems]. Comments welcome.

    Licensing and patents No concerns. Covered by Ecma International Royalty-Free Patent Policy. See also Ecma Code of Conduct in Patent Matters.
Transparency

As with most programming languages ECMAScript code is in readable text. Technically, it is binary source text as defined in RFC 4329, i.e, "a textual data object that represents source text encoded using a character encoding scheme." The ECMAScript specification does not prescribe encodings permitted for storing and transmitting ECMAScript source text; it merely requires that ECMAScript source text be a sequence of Unicode code points. If not specified otherwise, a browser assumes the source code of any program to be written in the local character encoding scheme (charset), which varies by country. Hence, in the browser context, it is often recommended that the charset used for embedded program code be declared explicitly, e.g., by using the same encoding declared in the <head> section of a parent HTML document or declared in a <script> tag that includes or refers to the source text. To avoid interoperability problems, it is also often recommended that only ASCII characters be used and that UTF-8 encoding be used. According to Encodings used in web development: UTF-16 and UTF-8 from JavaScript for Impatient Programmers, "HTML and JavaScript are almost always encoded as UTF-8 these days."

As a result, most ECMAScript or JavaScript files can be viewed in simple text editors. However, Javascript code to be used in HTML pages is often "minified," removing all unnecessary characters, such as spaces, tabs, line-breaks, and comments, all of which can make the source code easy to read, but are not necessary for it to execute. See Wikipedia entry on Minification.

Self-documentation The only method for describing the intended function of ECMAScript source code or its authorship and provenance is via comments embedded in the code. However, comments are often removed from the original source code as part of "minification" to reduce the size of the code and make network transfer and execution of the code more efficient.
External dependencies None beyond software for compiling or interpreting source code in the relevant host environment (e.g., web browser, web server, or PDF Reader).
Technical protection considerations The ECMAScript Language Specification provides no support for encryption or other form of technical protection. However, encryption may be supported through features in a particular host environment, for example, within PDF documents.

Quality and functionality factors Explanation of format description terms

Text
Normal rendering A "document" in ECMAScript or JavaScript is not a general text document. Like other programming languages, it is a textual file with defined special-purpose syntax.

File type signifiers and format identifiers Explanation of format description terms

Tag Value Note
Filename extension es
See https://www.iana.org/assignments/media-types/application/ecmascript
Internet Media Type application/ecmascript
See https://www.iana.org/assignments/media-types/application/ecmascript. See also RFC 4329.
Mac OS file type TEXT
See https://www.iana.org/assignments/media-types/application/ecmascript
Pronom PUID See note.  PRONOM does not have an entry specifically for an ECMAScript file. Files transmitted over the Internet for loading with HTML pages are typically identified as JavaScript. See signifiers for JavaScript files below.
Wikidata Title ID See note. 

Wikidata does not have an entry in Wikidata:WikiProject Informatics/File formats/Lists/File formats specifically for an ECMAScript file format. Files transmitted over the Internet for loading with HTML pages are typically identified as JavaScript. See signifiers for JavaScript files below.

Wikidata does have entries for ECMAScript as a programming language and versions/editions of the ECMAScript specification; see Wikidata search for 'ECMAScript'.

Tag Value Note
Filename extension js
See https://www.iana.org/assignments/media-types/application/javascript. See also IETF RFC 4329 for registration with IANA.
Internet Media Type application/javascript
See https://www.iana.org/assignments/media-types/application/javascript. See also IETF RFC 4329 for registration with IANA.

An update to RFC 4329 has been proposed, but not yet approved in an Internet Draft, draft-ietf-dispatch-javascript-mjs-05. This draft originated in October 2017.

Pronom PUID x-fmt/423
PRONOM entry for JavaScript file. See http://www.nationalarchives.gov.uk/PRONOM/x-fmt/423. PUID: x-fmt/423.
Wikidata Title ID Q5924007
Wikidata entry for JavaScript file. See https://www.wikidata.org/wiki/Q5924007.

Notes Explanation of format description terms

General

Relationship between ECMAScript and JavaScript: The relationship between ECMAScript and JavaScript has caused much confusion over the years. There is a distinction, but in informal contexts the terms are often used interchangeably. For example, Aki Rose, a member of the TC39 committee said in January 2019, "In this post while explaining where a certain programming language comes from, I use the terms “JavaScript” and “ECMAScript®” interchangeably. There is a difference, but it’s pedantic and not worth getting into today." The distinction between them is partly related to history, to the politics and time-frame of standardization, and partly to the context of use.

Key to the distinction is that the ECMAScript Language Specification is not self-sufficient. Any implementation must extend ECMAScript for a particular host environment. JavaScript, as the implementation used in browsers, extends ECMAScript with objects from the Document Object Model for HTML and a Browser Object Model. As of November 2019, the Wikipedia entry for JavaScript states, "JavaScript, often abbreviated as JS, is a high-level, interpreted scripting language that conforms to the ECMAScript specification" and the Wikipedia entry for ECMAScript states, "JavaScript has remained the best-known implementation of ECMAScript." A useful discussion of the relationship is at What is the difference between JavaScript and ECMAScript? on Stack Overflow. See Useful References below for links to more discussions of the relationship.

Techniques that allow web developers to use new ECMAScript features in older browsers: An interesting concept that is widely used on the web today to allow web developers to take advantage of new features in HTML or ECMAScript/JavaScript is that of the "polyfill." A polyfill is a piece of code (usually in JavaScript on the Web) used to provide modern functionality on older browsers that do not natively support it. The term was coined in 2009 by Remy Sharp, and is based on Polyfilla, a well known brand in the United Kingdom of a product roughly equivalent to what would be described as "spackling paste" in the United States. Why I love polyfills provides a simple introduction to how they are used. Sources of polyfills come in several forms, such as: core.js, a library of polyfills to incorporate individually or as a whole as JavaScript code; polyfill.io, a service that delivers browser-specific polyfills when the user loads a page; or polyfills for individual features (e.g., Promise Polyfill for the promise feature).

A second useful tool is a JavaScript "transpiler." A compiler is usually understood as a tool that converts source code in a high-level language to executable machine code. The term "transpiler" was coined to describe tools that convert code in one high-level language to another high-level lanuage or another version of the same language. Babel, a toolkit widely used by web developers, incorporates a JavaScript transpiler that can transform modern JavaScript code into an older version. Babel can also be used to apply polyfills to emulate new features of ECMAScript. Other JavaScript transpilers include:Bublé and Traceur.

History

See Useful References below for a selection of resources that illustrate or describe the early history of JavaScript and its standardization as ECMAScript.

The common abbreviated names used to refer to versions of ECMAScript over time have been a source of confusion. Through the 6th edition of ECMA-262, the common abbreviation was based on edition number, e.g., ES5 for the 5th edition. From 2015, the abbreviation based on the year has been used. As a result, the version published in 2015 is known both as ES6 and ES2015. The history of ECMAScript versions and features added prior to 2019 is most helpfully laid out in JavaScript Versions from w3schools.com.

Going forward, the situation is intended to be straightforward, for example, with the edition of ECMA-262 published in 2017 being referred to as ES2017. Features added to the ECMAScript specification in years after 2015 are documented as Finished Proposals in https://github.com/tc39/proposals/blob/master/finished-proposals.md.


Format specifications Explanation of format description terms


Useful references

URLs


Last Updated: 12/30/2020