Module that handles compression of JavaScript resources using GZip and script optimization that strips comments and extra whitespace.
This module should be used in conjunction with ClientScriptProxy.RegisterClientScriptResource which sets up the proper URL formatting required for this module to handle requests. Format is:
wwSc.axd?r=ResourceName&t=FullAssemblyName
The type parameter can be omitted if the resource lives in this assembly.
To configure the module in web.config (for pre-IIS7): <><system.web>
>
For IIS 7 Integrated mode: <><system.webServer>
>
Westwind.Web.ScriptCompressionModule
public class ScriptCompressionModule : object, IHttpModule
Class Members
Member | Description | |
---|---|---|
Constructor |
||
ScriptCompressionModuleActive |
Global flag that is set when the module is first loaded by ASP.NET and allows code to check whether the module is loaded. | |
Dispose |
public sealed void Dispose() |
|
GetClientScriptResourceUrl |
Works like GetWebResourceUrl but can be used with javascript resources to allow using of resource compression (if the module is loaded). public string GetClientScriptResourceUrl(Type type, string resourceName) |
|
GZipMemory |
Takes a binary input buffer and GZip encodes the input public static Byte[] GZipMemory(Byte[] buffer) public static Byte[] GZipMemory(string input) |
|
Init |
public sealed void Init(HttpApplication context) |
|
OptimizeScript |
Very basic script optimization to reduce size: Remove any leading white space and any lines starting with //. public static string OptimizeScript(string script) |
|
RegisterClientScriptResource |
Embeds a link to a script resource into the page including the script tags. Uses Page.ClientScript so the link is embedded into the page content rather than the header. public static void RegisterClientScriptResource(Type type, string resourceName) |
Requirements
Namespace: Westwind.WebAssembly: westwind.web.dll
© West Wind Technologies, 1996-2016 • Updated: 12/12/15
Comment or report problem with topic