开发者

Combine WebResource.axd CSS requests

开发者 https://www.devze.com 2023-01-16 13:26 出处:网络
I have developed some ASP.NET server controls which include their own javascript and css files.A lot of these controls use jQuery extensions which, as you know, often include their own css files.

I have developed some ASP.NET server controls which include their own javascript and css files. A lot of these controls use jQuery extensions which, as you know, often include their own css files.

I'm using Telerik's RadScript manager which combines the javascript like a boss. However, I'm using the AjaxToolkit's ClientCssResource attribute to include the cs开发者_开发问答s files in my server controls, and I have noticed that the CSS files are not getting combined at all. My pages have 10-15 WebResource.axd requests for css files for my server controls.

Everything I find only is about combining javascript, and nothing tells me how I can combine the CSS files. Does anyone know if there is a way to combine the CSS dynamically (I don't want to manually combine as each page might use a different subset of the server controls)?


You will need to write your own IHttpHandler for this. There is a working example at Combine Multiple JavaScript and CSS Files and Remove Overheads.


Optimize WebResource.axd and ScriptResource.axd

That also compresses them.

It's important to make sure it doesn't become an extra vector of attack for the padding oracle in the wild. Make sure that if it receives any garbage / resource not found it fails with an exception and the ms workaround is implemented.


The CombineAndMinify package (http://www.codeproject.com/Articles/125159/Package-that-speeds-up-loading-of-JavaScript-CSS-a) will combine and minify the WebResource.axd files with the CSS definitions (the ones that get loaded via link tags in the head of the page). Not sure if it will help in your case, but it is definitely worth a try.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号