See also
GitHub repo for source code.
Note
If you are loading JavaScript libraries on a page you should use a loader (count of 1). Why not use ours?
To simplify loading of CSS and JS libraries. The API Loader automatically works out the order the libraries should be loaded based on dependencies between them. It also skips libraries that already exist on a page or that pass a specific check.
Note
If you are passing a string or an Array as the first parameter into the library these are @deprecated but still working for backwards compatibility.
First you require the API Loader. You can for example use the following shorthand notation that always points to the latest version.
<script src="http://cdn.intermine.org/api"></script>
Now you can use the loader by passing in an object that looks for example like so:
intermine.load({
'js': {
'JSON': {
'path': 'http://cdn.intermine.org/js/json3/3.2.2/json3.min.js'
},
'setImmediate': {
'path': 'http://cdn.intermine.org/js/setImmediate/1.0.1/setImmediate.min.js'
},
'example': {
'path': 'http://',
'test': function() {
return true;
}
},
'async': {
'path': 'http://cdn.intermine.org/js/async/0.2.6/async.min.js',
'depends': ['setImmediate']
},
'jQuery': {
'path': 'http://cdn.intermine.org/js/jquery/1.8.2/jquery.min.js',
'depends': ['JSON']
},
'_': {
'path': 'http://cdn.intermine.org/js/underscore.js/1.3.3/underscore-min.js',
'depends': ['JSON']
},
'Backbone': {
'path': 'http://cdn.intermine.org/js/backbone.js/0.9.2/backbone-min.js',
'depends': ['jQuery', '_']
}
}
}, function(err) {
// your libraries have loaded
});
The object works like so: