However, if your page-specific code requires this library code, it is only natural to place a
@require directive there. By default, this will result in your library code being concatenated and minified into a single page-specific file, along with your page-specific code. Unfortunately, your user's browsers will not recognize that most of this file is library code that could be cached. How could it? As a result, you will completely miss out on the browser's ability to cache commonly-requested files from your site. Instead, you will be forcing the browser to re-download your libraries on each page.
That's not good. That's bad.
Fortunately, MinCat allows you to single out specific files as libraries. When MinCat encounters a
@require directive that points to a known library file, MinCat simply ignores it.
It is your responsibility to ensure that the libraries are actually on the page. MinCat minimizes at compile-time, not at run-time, and it cannot know what your page actually looks like. If you tell MinCat that a library is available, MinCat will trust that it is so.
To declare a file as a Library file, edit the
Many sites have public-facing pages and an administrative interface. The library files in the administrative interface may be very different from the library files on the public-facing pages. Alternatively, perhaps your site has a series of themes, and each theme includes its own set of libraries.
Fortunately, MinCat provides full support for the idea that a single site might have multiple minimization contexts. When MinCat minimizes a set of scripts, it will produce a separate minimized version for each configured minimization context.
For instance, consider this file:
/* @require "jquery.js" @require "jquery-ui.js" @require "bootstrap.js" */
By default, MinCat will produce a single minimized file that will contain the contents of
bootstrap.js, and this file itself.
Now consider that MinCat is configured with two contexts, and admin and a public context:
<Context name="public"> <Input include="*.csproj" exclude="**\*.min.js" /> <Library include="jquery.js; bootstrap.js" /> </Context> <Context name="admin"> <Input include="*.csproj" exclude="**\*.min.js" /> <Library include="jquery.js; jquery-ui.js; bootstrap.js" /> </Context>
Given this configuration, MinCat will produce two minimized files: one for the admin context and one for the public context. The public file will contain
jquery-ui.js and the file, but the admin context will contain only the file itself.