Advanced Usage / Extending Squish.NET
List dependencies between your resources

In your SquishMap class, add the SquishDependsOn attribute to any Squish resource and Squish.NET will automatically include those resources. In this example, if you register the "TruckDriver" resource, the "Person" resource will automatically be included.
As an added bonus, the "Person" resource will be delivered before the "TruckDriver" resource when the user's browser parses the file.

Explicitly sequence your resources
Sometimes resources must be delivered to the user before other resources. This might occur if you have CSS definition that will override generic CSS styles or if you have JavaScript resources that rely on functions defined in other files.
In your SquishMap class, you can use the overload to the SquishJs or SquishCss attributes to specify the sequence that this resource should be delivered. In this example, the "LeftMenu" and "TopMenu" CSS definitions will be placed after the "Core" CSS definitions.
Easy access to individual resources via querystring parameters
If you ever need to reference your individual resources (from static HTML pages for instance), you can do so with this simple syntax:
[YOUR DOMAIN]/Squish.axd?key=[YOUR RESOURCE KEY]&type=[RESOURCE TYPE]
Where [YOUR RESOURCE KEY] is the key you would normally register in your .NET application and [RESOURCE TYPE] is "js" or "css" (or any custom resource type that you choose to implement).
Here's a simple example for a stylesheet from this website:
http://www.OpenBracketLLC.com/Squish.axd?key=Main&type=css
Configuration options in your web.config
| minifyJavaScript | Set to false if you do not want Squish.NET to compress your JavaScript. It is helpful to turn minification off when debugging. |
| minifyCss | Set to false if you do not want Squish.NET to compress your cascading stylesheet definitions. |
| minifyPageOutput | Set to true if you want Squish.NET to compress every page in your site. NOTE: In rare cases, your site may be written in such a way that Squish.NET compression alters the way it appears to your users, as whitespace becomes greatly reduced. |
| allowDiagnostics | It is a good idea to turn diagnostics off on production environments. The diagnostic information is helpful when verifying that your SquishMap class is set up appropriately. See Squish.NET How-to Guide for more details. |
| mapType | Specifies the type name of your SquishMap class and is the only required setting. |
| customEngineFactoryType | Advanced usage only: specifies the type name of a custom engine factory class (see paragraph below). |
<!-- Customize Squish.NET -->
<squish minifyJavaScript="true" minifyCss="true" minifyPageOutput="true" allowDiagnostics="true">
<mapType>SampleData.SquishMap,SampleData</mapType>
<customEngineFactoryType>SampleData.CustomSquishEngineFactory,SampleData</customEngineFactoryType>
</squish>
Extend Squish.NET to handle other types of resources
Write your own class that extends SquishNet.Engine.EngineFactory and deliver other types of resources in a similar manner as Squish.NET delivers JavaScript or CSS. Write your own class that extends SquishNet.Engine.EngineBase to apply special processing logic to other types of resources (XML, CSV, etc.).
Your custom engine factory would look something like the screenshot below, but you would want to match resourceType to your custom resource type and return the appropriate EngineBase for that type of resource.

IMPORTANT: To enable your factory instead of the standard Squish.NET factory, be sure to specify your class in the Squish.NET configuration settings (see above -- customEngineFactoryType).

If you created your own XML resource type, you would register resources of this type in your SquishMap class something like this:
Return to Top