Loader Class

Matt Karl edited this page Sep 25, 2015 · 9 revisions

Loader is a singleton for interacting with CreateJS's PreloadJS. Some of the features of Loader include, browser cache control, priority queuing and setting simultaneous maximum downloads. Loader is included in the Core Module and accessible from the namespace springroll.Loader.


var app = new springroll.Application();

app.on('init', function()
	this.loader.load("assets/config.json", function(result)
		// Result returned as a LoaderResult
		var json = result.content; // the load contents


###load(url, callback, [updateCallback[, priority=0]])


  • url string The relative (recommended), root-relative or absolute path to an asset to load.
  • callback function The callback function when the load completes.
  • updateCallback function (optional) The callback function on load progress updates. Passes 0-1 as the only parameter.
  • priority int (optional) The load priority, generally low is -1, normal is 0 (default) and 1 is high.



  • Type: int
  • Default: 2

The maximum number of simultaneous loads that can happen at the same time.


  • Type: springroll.CacheManager
  • Default: instance of springroll.CacheManager

The CacheManager is responsible for managing the formatting of URLs and managing the browser cache. If you are attempting to load a file outside of Loader, it would be important to call the prepare() method on the CacheManager.

var app = new springroll.Application({
	basePath : 'http://cdn.example.com/',
	cacheBust : true,

app.on('init', function()
	// The prepare method has two parameters, the first is the url, the second 
	// a boolean if the basePath should be applied.
	var url = this.loader.cacheManager.prepare("assets/example.txt", true);
	console.log(url); // returns "http://cdn.example.com/assets/example.txt?v=1230912380"

API Documentation

To see the full list of methods available to springroll.Loader please see the full documentation.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.