Montage Require: a CommonJS module system for front-end web application development
Pull request Compare This branch is 15 commits ahead of montagejs:v2.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
bin Move bin specific code into bin/mr Mar 20, 2014
boot Fixes for booting May 19, 2014
demo Add a bit more complete demo May 18, 2013
docs Split code example into two blocks May 18, 2013
node_modules Fix Mr/Jasminum/PhantomJS tests May 19, 2014
phantom Shift from qs to query-string Feb 8, 2015
test Remove support for implicit inheritance Apr 4, 2015
.gitignore Resort .gitignore Feb 8, 2015
.jshintignore JSHint review Mar 20, 2014
.jshintrc JSHint review Mar 20, 2014
.npmignore Add some dotfiles and sort npmignore Jul 29, 2013
.travis.yml Upgrade npm on Travis Feb 8, 2015 Update changelog for v0.13.4 Sep 5, 2013 FIRST! Aug 20, 2012 Correct markdown links for github May 18, 2013
adhoc.html Fix adhoc boot Mar 20, 2014
adhoc.js Shift from qs to query-string Feb 8, 2015
boot.js Rebuild boot script Apr 4, 2015
browser.js Improve display name of module factories Mar 20, 2014
build.js Eliminate shared module cache for builder Aug 5, 2014
common.js Remove support for implicit inheritance Apr 4, 2015
identifier.js Add isRelative check for identifiers Mar 15, 2015
merge.js Factor merge and identifier modules Sep 5, 2014
mini-url.js Fix Mr/Jasminum/PhantomJS tests May 19, 2014
package.json 2.0.7 Apr 5, 2015
parse-dependencies.js Factor parse dependencies into module Mar 15, 2015
require.js Switch sourceURL to new style Feb 6, 2015
sandbox.js Add documentation Sep 13, 2013
script.js JSHint review Mar 20, 2014

Montage Require

This is a CommonJS module system, highly compatible with NodeJS, intended for front-end development of web applications using npme style packages. It is designed to be automatically replaced by the Montage Optimizer with a smaller, faster and bundled production module system.

Mr is installed as a package in your application using npm:

$ npm init                  # if you don't already have a package.json
$ npm install --save mr

In an HTML file next to your package.json add the Mr script and provide a module to load:

<script src="node_modules/mr/bootstrap.js" data-module="index"></script>

Start writing your code in index.js, using the require function as you would in Node. Have a look at the demo for working example.

You can place your package.json in a different location, or avoid having one at all, with other script tag attributes.


Take a look at Mop, the Montage Optimizer to optimize applications for production. The optimizer can bundle packages with all of the dependent modules, can preload bundles of progressive enhancements in phases, and can generate HTML5 application cache manifests.


Mr is compatible with Node and npm, although there are some differences.

There is documentation for:

And you may be interested in an in-depth look at how Mr works.


At present, Mr depends on document.querySelector and probably several other recent EcmaScript methods that might not be available in legacy browsers. With your help, I intend to isolate and fix these bugs.

At time of writing, tests pass in Chrome 21, Safari 5.1.5, and Firefox 13 on Mac OS 10.6.


Tests are in the spec directory. Use npm test to run the tests in PhantomJS or open spec/run.html in a browser.

This implementation is a part from Motorola Mobility’s Montage web application framework. The module system was written by Tom Robinson and Kris Kowal. Motorola holds the copyright on much of the original content, and provided it as open source under the permissive BSD 3-Clause license. This project is maintained by Kris Kowal and Stuart Knightley, continuing with that license.