NOTE: You are viewing documentation for the MoovJS/Adapt version of the Moovweb SDK
View documentation for next-gen Moovweb XDN & PWA framework
Moovweb | moov_stdlib
Menu Developer Moovweb University


A small library of functions for efficiently manipulating HTML.


This module contains the critical functions used by Moovweb projects to transform the web. It provides the fns object used to organize the DOM within the Moovweb Node Environment. A version of moov_stdlib is required for MoovJS projects to run, and the version to be used by a given project can be specified in that project's package.json file.


Documentation examples will reference method calls as part of the fns namespace, and any associated HTML input and output is explicitly specified in the examples' comments.


Quick Start

After entering your project's directory, you can install your required dependencies locally with:

$ cp .npmrc.example .npmrc
$ npm install


You will not need to instantiate the moov_stdlib module in your MoovJS projects directly; this is done at the sandbox level inside the Node server that will be running your project code. For running the module locally or in a terminal, a context object can be passed to the constructor to simulate the environment and headers of an incoming http request. See test/fixed_job.json for an example context file.


const moov_stdlib = require("moov_stdlib")(ctx);

This is currently done at the sandbox level and exposed as the fns object when running code on the Moovweb Cloud.

The following examples will refer to fns, which is effectively an interface to the module.exports of the moov_stdlib module.


init$ exposes the global $ function, which can be used to select nodes from the root scope, no matter where you are in your code. You'll generally want to avoid this (since it signifies traversal from the root) - you should instead utilize the $html, $head, and $body globals.


An interface for adding and removing headers from the current request.

headers.header(key, val);
headers.addHeader(key, val);


Within your MoovJS project, stdlib methods are invoked using the fns namespace.




To run the test suite, enter the following command in your Terminal:

$ npm test

Run Locally via Node CLI

Optionally, to run this module from inside the node CLI on its own, you can require the main.js file explicitly via:

$ node --harmony
> var moov_stdlib = require("./main.js");
Last updated Mon Feb 26 2018 22:51:29 GMT+0000 (UTC)