Mixers (Tritium Libraries)

Tritium libraries (known as “mixers”) add specific functionality to your project. Mixers in Tritium are like gems in Ruby or modules in Node.js.

Every Moovweb project starts off with at least two mixers that you can find in the Mixer.lock file. A sample Mixer.lock file is shown below:

core-rewriter (2.1.109)
stdlib (2.0.64)

You may add additional mixers to your project, such as our json mixer or our jquery-mobile mixer.

The Core Mixer

The core mixer controls your project configuration. It reads the config.json file in the project’s root folder to manage HTTP communications with the source site(s).

Every project needs a core mixer specified in its Mixer.lock file. The latest core mixer is automatically added when you generate your project. It can also be updated just like any other mixer.

In the Mixer.lock file example above, the core mixer used was core-rewriter (2.1.109). If your project’s Mixer.lock file does not have a core mixer listed, you will not be able to start the server. You will see the following error:

Running moov (version 4.x.xxx)
ERROR: your project must specify an HTTP transformer mixer in Mixer.lock

This means that your Mixer.lock file does not have a core mixer. You must add a core mixer into your Mixer.lock file — the default currently is core-rewriter (2.1.109).

Ack, I only have one mixer in my Mixer.lock file called simple-mobile (1.0.224)! What do I do?

Our first generation of mixers were called simple-mobile (1.0.xx). They contained core functionality as well as Tritium transformation functions. If you’re using a first-gen simple-mobile mixer (like, say simple-mobile (1.0.224)), your project will continue to run fine. However, you CANNOT add on new mixers like stdlib, jsonlib, or jquery-mobile. Even though simple-mobile (1.0.xx) mixers are still supported, we recommend you upgrade to core-rewriter (2.1.109) and stdlib (2.0.64).

I have simple-http-transformers (2.0.6) and simple-mobile (2.0.11) mixers in my Mixer.lock file. Am I set up ok?

Those mixers have been deprecated; please upgrade to core-rewriter (2.1.109) and stdlib (2.0.64) ASAP. Just to be clear: simple-mobile (1.0.xx) mixers are still supported, but simple-mobile (2.0.xx) and simple-http-transformers (2.0.xx) are not.

List of Mixers

In addition to the core mixer, we have a number of mixers that provide different kinds of functionality. The most important mixer is stdlib which contains all the standard Tritium functions and is automatically included when you generate a project.

Our available mixers include:

Standard Tritium functions needed for every project
Convert HTML to JSON.
Helpers to implement jQuery Mobile.
Optimize images and JavaScript.
Test your Tritium to monitor for breaks.
Enable caching to improve site performance.
Functions for developing Single-domain project.

Please visit tritium.io for a complete list of mixers, versions, and changelogs.


Periodically, Moovweb introduces new functionality by creating new mixers or upgrading existing ones.

To use a mixer, simply add the mixer name and version to your project’s Mixer.lock file. For example, add the line “jsonlib (2.0.12)” to your Mixer.lock file to use the JSON mixer. Or, change the version from stdlib (2.0.12) to stdlib (2.0.64) to get a newer standard mixer.

Then, restart your server. Any new mixers will be downloaded automatically and can be used in your project.

To remove a mixer from your project, simply delete the appropriate line from your Mixer.lock file.

Some mixers require a minimum version of the SDK. For example, if you’re using Moovweb SDK 4.2.193, you cannot run projects with the stdlib (2.0.64) mixer. Instead, you’ll get a warning notice when you start the server asking you to upgrade to SDK 4.4+. As in our installation and upgrading guidelines, old mixers will always work with new SDK versions.

Create Your Own Mixers

Unfortunately, you cannot as yet create and distribute your own mixers. We’re working on it!

However, Moovweb allows you to define your own functions in the functions/main.ts file. You can write functions in separate files in the functions folder and then use the @import function to import them into functions/main.ts.

The basic definition syntax looks like:

@func ScopeType.funcName(ArgType %argName) {
  log(%argName) # Comments are just fine

There are a number of variables within this:

scope that your new function is defined within. It affects what data your function can operate on. For example, if you want the function to be performed on XML nodes only, set the scope type to “XMLNode”. The ScopeType also determines which functions you can call within your definition.
name of your function
scope in which the %argName will be entered. For example, if you want to enter an argument that is pointing to a particular node with XPath, “XMLNode” is an appropriate ArgType.
property which will be entered in the function

For more details on writing your own functions, please read our notes on writing Tritium functions.

Functions can be scoped into namespaces. For more details, please read our docs on namespaces.