encyclopegia.org

Asm.js

asm.js is a subset of JavaScript designed to allow computer software written in languages such as C to be run as web applications while maintaining performance characteristics considerably better than standard JavaScript, which is the typical language used for such applications. asm.js consists of a strict subset of JavaScript, into which code written in statically typed languages with manual memory management (such as C) is translated by a source-to-source compiler such as Emscripten (based on LLVM). Performance is improved by limiting language features to those amenable to ahead-of-time optimization and other performance improvements. The project was started at Mozilla, and Firefox 22 released in 2013, was the first web browser to ship asm.js-specific optimizations. Compiler and browser makers' experience with asm.js influenced the development of WebAssembly, which has largely supplanted asm.js since its release. Firefox 148, shipped in 2026, disabled asm.js optimizations and asm.js, with old code transparently continuing to run using the main JavaScript engine.

asm.js is a subset of JavaScript designed to allow computer software written in languages such as C to be run as web applications while maintaining performance characteristics considerably better than standard JavaScript, which is the typical language used for such applications. asm.js consists of a strict subset of JavaScript, into which code written in statically typed languages with manual memory management (such as C) is translated by a source-to-source compiler such as Emscripten (based on LLVM). Performance is improved by limiting language features to those amenable to ahead-of-time optimization and other performance improvements. The project was started at Mozilla, and Firefox 22 released in 2013, was the first web browser to ship asm.js-specific optimizations. Compiler and browser makers' experience with asm.js influenced the development of WebAssembly, which has largely supplanted asm.js since its release. Firefox 148, shipped in 2026, disabled asm.js optimizations and asm.js, with old code transparently continuing to run using the main JavaScript engine. int f(int i) { return i + 1; } Emscripten would output the following JS code: function f(i) { i = i | 0; return (i + 1) | 0; } Note the addition of | 0 and the lack of type specifiers. In JavaScript, bitwise operators convert their operands to 32-bit signed integers and give integer results. This means that a bitwise OR with zero converts a value to an integer (a very simple "conceptual" presentation of bitwise operators may not deal with type conversion at all, but every programming language defines operators for its own convenience, as Javascript does here). By doing this for each parameter, this ensures that if the function is called from outside code, the value will be converted to the correct type. This is also used on the return value, in this case to ensure that the result of adding 1 to i will be an integer (as otherwise it could become too large), and to mark the return type of the function. These conversions are required by asm.js, so that an optimising compiler can produce highly efficient native code ahead-of-time. In such an optimising compiler, no conversions are performed when asm.js code calls other asm.js code, as the required type specifiers mean it is guaranteed that values will already have the correct type. Furthermore, rather than performing a floating-point addition and converting to an integer, it can simply do a native integer operation. Together, this leads to significant performance benefits. Here is another example to calculate the length of a string: size_t strlen(char* s) { char* current = s; while (*current != 0) { ++current; } return (current - s); } This would result in the following asm.js code: function strlen(s) { s = s | 0; var current = 0; current = s; while ((MEM8[current >> 0] | 0) != 0) { current = (current + 1) | 0; } return (current - s) | 0; } In the generated code, the variable MEM8 is actually a byte-by-byte "view" of a typed buffer, which serves as the "heap" of the asm.js code.

References

No reference rows published for this article.

Cite this article

MLA

"Asm.js." encyclopegia.org, 2026, https://encyclopegia.org/wiki/asm-js. Accessed 25 November 2026.

Chicago

"Asm.js." encyclopegia.org. Accessed November 25, 2026. https://encyclopegia.org/wiki/asm-js.

APA

encyclopegia.org. (2026). Asm.js. Retrieved November 25, 2026, from https://encyclopegia.org/wiki/asm-js

Accessed November 25, 2026 · CC BY-SA 4.0 · citation page · JSON

Claims

PredicateValueSource
release date2013Wikipedia

Related articles

JS Suō

stub · references available

(15809) 1994 JS

stub · references available

JS El Biar

stub · references available

list of JS Kabylie players

stub · references available

1969–70 JS Kabylie season

stub · references available

JS Air Flight 201

stub · references available

(80022) 1999 JS

stub · references available

ASM-N-5 Gorgon V

stub · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1375185192 · 0.5 · snapshot enwiki-001375185192

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.