Documentation

Adding external URLs

In addition to local files, you can define bundles based on external URLs. Cassette won't process these bundles, however the URLs are used when rendering the HTML.

bundles.AddUrl("http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js");

Then another script can reference this bundle.

/// <reference path="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"/>
$(function() {
    ...
});

However, it can be easier to define an alias for the bundle.

bundles.AddUrlWithAlias(
    "http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js",
    "~/jquery"
);

Then the reference can use the alias instead.

/// <reference path="~/jquery"/>
$(function() {
    ...
});

URL with local fallback assets

If a remote URL fails to load you can fallback to using a local bundle.

bundles.AddUrlWithLocalAssets(
    "//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js",
    new LocalAssetSettings
    {
        FallbackCondition = "!window.jQuery",
        Path = "scripts/jquery.js"
    }
);

This will generate the following HTML.

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
    if (!window.jQuery) {
        document.write(unescape('%3Cscript src="/cassette.axd/script/PlxtfG4Jll0234wePZ3KZGLEHsE=/scripts/jquery.js" type="text/javascript"%3E%3C/script%3E'));
    }
</script>

Note that this feature will only be activated if debug mode is off (see web-config)