Skip to content

I have dynamc javascript. Will RequestReduce process that and for how long? Why are some scripts never crunched?

mwrock edited this page Nov 11, 2011 · 7 revisions

RequestReduce does not process every script on the page carte blanche. Did I really just use that phrase?

RequestReduce will ignore the following scripts:

  • Scripts that do not have a propper javascript mime type
  • Scripts with a Cache-Control header set to no-cache or no-store
  • Scripts with an Expires or max-age header less than a week
  • Scripts included in the javascriptUrlsToIgnore list

By default, the google and microsoft jquery CDNs are in the ignore list. You can specify your own list by supplying a list of comma separated url substrings to the javascriptUrlsToIgnore setting. The entries just need to be a substring. If the actual url that RequestReduce is considering for processing contains any of these substrings, ReuestReduce will not process he script.

You can also use more complicated or customized rules via code. RequestReduce exposes a Func<string, string, string> for approving the processing of urls. You can hook into this by registering a lambda or delegate to this Func in your Global.asax startup. Here is an example:

RequestReduce.Api.Registry.AddFilter(new JavascriptFilter(x => x.HttpRequest.RawUrl.Contains("dynamic")));

The first input param is the full script tag eleent and the url is the javascript SRC.

By the way, you can do the same thing with CSS using RRContainer.Current.GetInstance<CssResource>().

Clone this wiki locally