mwrock / RequestReduce

Instantly makes your .net website faster by reducing the number and size of requests with almost no effort.
www.requestreduce.org
Apache License 2.0
228 stars 48 forks source link

Process CSS links outside of the <head> element #151

Open candrews opened 12 years ago

candrews commented 12 years ago

Request Reduce currently only processes CSS 's inside the element.

It would be nice if RR could process CSS 's wherever it finds them. This would help social media widgets (which tend to do this) and not so well designed "legacy" users.

Also, I understand that it wouldn't be a significant change (according to my email exchange with Matt).

cmjacques commented 12 years ago

If this change is made then would it be possible to tell RR to ignore certain CSS files?

In one of my projects I am generating a CSS file per client and the CSS can change quite often. I'm currently serving it up from inside the <body> so RR leaves it alone. It would be great to move it back to the <head> and tell RR to ignore it.

Cheers, Chris

jonespen commented 12 years ago

Chris, I belive its possible to exclude certain css files with something like this

Registry.AddFilter(
    new CssFilter(
        context =>
        {
            var url = context.FilteredUrl;
            if (url.ToLower().Contains("rr=disabled"))
                return true;
        }
    )
);

and <link rel="stylesheet" href="style.css?rrfilter=disabled">

setiseeker commented 12 years ago

One issue we have is where we build up html on the fly using Jquery and in the script that does the building, we have a .css file in the correct link tags, RR is doing its thing to the css file ref in our jquery script.

But we only use the web.config to setup the handler and do not what to directly reference the code in our project, so we would need a config option similar to the ignoreJavascript option in the configuration.