Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Asynchronous Javascript dependency manager
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
inc
qunit
LICENSE
README.textile
index.html
malt.js
tests.js

README.textile

Malt

An asynchronous JavaScript dependency management library.

Features

  • JavaScript files are loaded asynchronously via XHR
  • Preserves execution order of scripts
  • Prevents multiple includes of the same file
  • Can declare modules / aliases for groups of resources
  • Supports multiple file types:
    • JavaScript
    • Images (which become preloaded)
    • Stylesheets

Usage

NOTE: See tests.js for live examples. Or run the test suite live.

Single file

If you have a block of code that depends on a single JavaScript file.


Malt.require('js/sammy.js', function() {
  // execute this block once files are loaded
});

Multiple files

If you have a block of code that depends on multiple JavaScript files.


Malt.require('js/sammy.js', 'js/cufon.js', function() {
  // execute this block once files are loaded
});

Multiple file types

You can require multiple file types, including image files and css.


Malt.require('js/facebox.js', 'css/facebox.css', function() {
  // execute this block once files are loaded
});

Modules

You can declare modules/aliases for groups of resources.


Malt.module('facebox', 'js/facebox.js', 'css/facebox.css', function() {
  // initialize facebox
});

Malt.require('facebox', function() {
  // execute after all resources loaded, initialized
});

Nested module dependencies


Malt.module('package1', 'a.js', 'b.js');
Malt.module('package2', 'package1', 'c.js');

Malt.require('package2', function() {
  // executes when a.js, b.js and c.js have all been loaded
});

License

MIT License. See LICENSE for more information.

Malt includes code originally created by Steve Souders (asynchronous script loading).

Something went wrong with that request. Please try again.