By default each of the RadControls for ASP.NET Ajax serves a set of files (stylesheets) needed for its proper client-side look.
When loading a page with several controls on it, the number of these files can become very large, often resulting in a reduced page load time and increased traffic. The reason for this problem is that browsers make a separate request to the server for each of these resources.
Usually this problem is overcome by disabling the automatic stylesheet serving of the controls, combining them into a smaller set of files and registering the links to these files manually on the page.
This approach is not the best for of a number of reasons:- you must extract the files from the assembly for each control release;- files become too large to be maintainable (or you have to write a script to merge the source files);- the number of merged files you need to maintain can become very large depending on the control sets you have on different pages;
With the newly added RadStyleSheetManager control, RadControls for ASP.NET Ajax suite gives developers the advantage of a simple drag-and-drop to achieve the combination of resources to a single request. All you need is to add a RadStyleSheetManager to your page and the stylesheet requests will be combined into a single request.
Note |
|---|
The performance gain of RadStyleSheetManager should be monitored on a remote server, but not in a local development. This is, because the control optimizes the network latency delay when loading the resources. This comes at the cost of some processor load, because the resources get combined and compressed on the server.
When testing locally, the largest part of the result you get is the time RadStyleSheetManager takes to combine the resources and serve them to the browser.
|
RadStyleSheetManager needs an HttpHandler to be declared in the application configuration file to operate properly. The addition of the handler is made easy by the SmartTags of the control:
As the RadStyleSheetManager control uses ASP.NET 2.0 WebResource capabilities it benefits from gzip content compression (for browsers, supporting that) and script caching.
Similar to RadScriptManager, RadStyleSheetManager combines all the requests (to the "stylesheet resource files" on the page) into a single one, reducing the page load time and traffic. The difference is that it does not replace the ScriptManager, but instead works together with it.
RadStyleSheetManager outputs a <link> tag with a specific URL, making a request to an HttpHandler, which serves the combined scripts.
RadStyleSheetManager also needs the HttpHandler to be registered in the application's configuration file, e.g.
Copyweb.config
<configuration>
<system.web>
<httpHandlers>
<add path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResource, Telerik.Web.UI" validate="false" />
</httpHandlers>
</system.web>
</configuration>
The actual URL of the HttpHandler can be changed using the HttpHandlerUrl property of the control.
If the stylesheet combination is not needed for some reason (e.g. debugging) it can be disabled by setting the EnableStyleSheetCombine property to false.