Testing $.cacheFactory

by abernier

HTML

<script src="https://raw.github.com/gist/1144288/jquery.cachefactory.js"></script>
<script src="https://raw.github.com/gist/1144288/gistfile1.js"></script>

JavaScript

var script1 = 'https://raw.github.com/janl/mustache.js/master/mustache.js',
    script2 = 'https://raw.github.com/documentcloud/underscore/master/underscore.js';

// Testing { is only loaded once
$.cachedGetScript(script1).done(function () {alert('{');});
$.cachedGetScript(script1).done(function () {alert('{');});

// Testing _ is only loaded once and { is not reloaded
$.cachedGetScript(script2).done(function () {alert('_');});
$.cachedGetScript(script1).done(function () {alert('{');});
$.cachedGetScript(script2).done(function () {alert('_');});

// Testing { and _ together
$.when(
    $.cachedGetScript(script1),
    $.cachedGetScript(script2)
).done(function () {alert('_{')});