Maximum Tension™ . Teoman Deniz . maximum-tension.com
License: MIT . Created 2013/11/04
JS (JavaScript Framework) is a small utility framework for browsers, old Internet Explorer and the Windows Script Host: type checks, cloning, iteration, string templates, DOM helpers, AJAX and storage behind one uppercase API.
I made it because I was writing the same helpers on every project. Now I drop one file in and use the globals. The same code reads the same in a modern browser, in old Internet Explorer and in a cscript automation script.
- No build step, no dependencies. Copy one file, add one
<script>tag, done. - Three builds, one API.
JS.js,IE.jsandWSCRIPT.jsshare the same names, so you don't relearn anything when the environment changes. - One AJAX result everywhere. Every request gives
{STATUS, DATA}and never throws, in all three builds. - Modern syntax on old IE.
IE.jsrewrites<script type="module">blocks (let,const, arrow functions, template literals) so IE can run them.
Table of Contents
| Build | File | Environment | Language level | AJAX style |
|---|---|---|---|---|
| Modern | JS.js |
Modern browsers | ES6+ (const/let, arrow fns, Promise, async) |
Asynchronous, returns a Promise |
| Legacy | IE.js |
Internet Explorer and old browsers | ES3 (var, function expressions) |
Synchronous, ActiveXObject then XMLHttpRequest |
| Shell | WSCRIPT.js |
Windows Script Host (cscript/wscript) |
ES3 (var, function expressions) |
Synchronous, ActiveXObject |
Each build puts its API on plain globals: JS, and depending on the build some of WINDOW, DOM, AJAX, WS and LOCAL_STORAGE.
You load exactly one build per program. They are not meant to be combined.
JS.jsis the default for anything running in an up-to-date browser. AJAX returns promises, so youawaitit.IE.jshas the same API asJS.js, but it runs on Internet Explorer and other old engines. AJAX is synchronous (noawait). It also polyfillsPromise,JSONandFunction.prototype.bind.WSCRIPT.jsis for automation scripts under the Windows Script Host. There is no browser there, so it drops every DOM andwindowhelper and adds console I/O, file I/O and message boxes.
You can also find the Mini versions of these frameworks here.
<!--[if IE]>
<script type="text/javascript" src="IE.js"></script>
<![endif]-->
<!--[if !IE]>-->
<script type="text/javascript" src="JS.js"></script>
<!--<![endif]-->
<script>
DOM.START(
function()
{
WINDOW.TITLE("Ready");
var BOX = DOM.GET.ID("app");
DOM.CLASS.ADD(BOX, "loaded");
}
);
</script>IE.js is a drop-in replacement. Swap the src and the same code runs on old engines, with AJAX returning the result directly instead of a promise.
Write your page code in <script type="module">. Modern browsers run it natively. Old IE skips module scripts by itself, and IE.js picks them up, rewrites them with JS.TRANSPILE and runs them before your DOM.START callbacks.
<script type="module">
const NAMES = ["Ada", "Linus"];
JS.ITERATE(NAMES, NAME => DOM.GET.ID("list").innerHTML += `<li>Hello ${NAME}</li>`);
</script>
<script type="module" src="app.js"></script>On IE, that first block runs as:
var NAMES = ["Ada", "Linus"];
JS.ITERATE(NAMES, function(NAME){return (DOM.GET.ID("list").innerHTML += ("<li>Hello " + (NAME) + "</li>"));});Only
let/const, arrow functions and template literals are rewritten.Classes, destructuring,
for...of, spread, default parameters,async/awaitandimport/exportare not. Built-in methods likeArray.prototype.mapare not polyfilled either. Full list in JS.md.
cscript //nologo yourscript.js// yourscript.js
JS.ECHO("Building...\n");
var RES = AJAX.GET("https://api.example.com/status");
if (AJAX.OK(RES))
JS.INFO("Up: " + RES.DATA.state, "Status");
else
JS.ERROR("Down (" + RES.STATUS + ")", "Status");Every object and function is documented here:
- JS.md for the browser builds,
JS.jsandIE.js. - WSCRIPT.md for the Windows Script Host build,
WSCRIPT.js.
Not every namespace exists in every build. The browser-only ones are not in the shell build, on purpose.
| Namespace | Purpose | JS.js |
IE.js |
WSCRIPT.js |
|---|---|---|---|---|
JS (core utils) |
Type checks, clone, merge, iterate, template | OK | OK | OK |
JS.TRANSPILE |
Rewrites modern syntax for old engines | - | OK | - |
JS (I/O + dialogs) |
Console/file I/O, message boxes | - | - | OK |
WINDOW |
Title, favicon, popups, URL/navigation | OK | OK | - |
DOM |
Element create/query/class/attribute helpers | OK | OK | - |
AJAX |
HTTP GET, POST, DATA, DELETE, REQUEST |
Async | Sync | Sync |
WS |
WebSocket helpers | OK | OK | - |
LOCAL_STORAGE |
Typed localStorage wrapper |
OK | OK | - |
All three builds share one result shape. A request never throws and never rejects:
{STATUS: <number>, DATA: <object|string>}| Field | Meaning |
|---|---|
STATUS |
The HTTP status code. It is 0 when no HTTP response came back (network error, no XHR). |
DATA |
The parsed JSON body when it is valid JSON, the raw text when it is not, or "" when empty. |
| Call | Sends |
|---|---|
AJAX.GET(URL) |
Nothing |
AJAX.POST(URL, BODY) |
BODY as JSON, always ({} when left out) |
AJAX.DATA(URL, DATA) |
A string, FormData or Blob as it is, anything else as JSON |
AJAX.DELETE(URL, BODY) |
Same rules as DATA, the body is optional |
AJAX.REQUEST(METHOD, URL, BODY) |
Any method (PUT, PATCH, ...), same body rules as DATA |
AJAX.OK(RESULT) |
Nothing, it returns true for any 2xx status |
// JS.js
var RES = await AJAX.DELETE("/api/users/5");
// IE.js and WSCRIPT.js
var RES = AJAX.DELETE("/api/users/5");
if (AJAX.OK(RES))
console.log("Deleted");
else
console.log("Failed: " + RES.STATUS);I changed this in 2026/11. Before, every build had its own failure shape:
GETgaveundefined,POSTaddedSTATUSinto the server's JSON,DATArejected inJS.jsand gave{AJAX_STATUS, AJAX_MESSAGE}inIE.js. Only200counted as success. If you have old code that reads those, switch it toRES.STATUS/RES.DATAandAJAX.OK(RES).
AJAX.DATA stays because it is the upload call: it is the only one that sends FormData, Blob, File or a raw string. POST is the simple "send this object as JSON" call.
The framework follows one house style, and contributions should match it:
- Uppercase identifiers for the public API and local variables (
JS.IS_NULL,VALUE,TARGET). - Tabs for indentation.
- Parenthesized returns:
return (VALUE);. - JSDoc on every public function (
@param/@return).
- Synchronous AJAX blocks.
IE.jsandWSCRIPT.jssend blocking requests. That's fine for shell scripts but it freezes a browser page while it waits. UseJS.jswhere responsiveness matters. JSONunder WSH. Classic JScript has no nativeJSONobject.WSCRIPT.jsusesJSON.parse/JSON.stringify, so run it under an engine that has them, or include a JSON polyfill.- Module scripts on IE run synchronously. External
<script type="module" src="...">files are loaded with a blockingAJAX.GET, so they must be on the same origin. IE.jsand IE10/11. Conditional comments (<!--[if IE]>) only work up to IE9. IE10 and IE11 ignore them and getJS.js.
If something is broken or missing, open an issue here. Tell me which build (JS.js, IE.js or WSCRIPT.js), which browser or Windows version, and a few lines that show the problem.
MIT © Teoman Deniz - maximum-tension.com. See the LICENSE file.
