I've spent many hours trying to reduce page size by removing redundant spaces, tabs, and EOL marks. It seems no matter what I do, Telerik JavaScripts are going to cough somewhere. Is there a published bit of code which can be placed in the Render method which will reduce page size without adversely affecting scripts?
Please do not refer me to CodeProject, StackOverflow, or other googled resources unless you're sure something works. Many blogs and forum postings imply have wrong and/or incomplete info. Regular expressions are often cited but frequently wrong. I'm looking for code that people are actually using with Telerik RadControls for ASP.NET Ajax. With this, I and others may be able to improve upon it - but we need a better base than some unknown code that someone simply found somewhere on the net.
On the flip-side of this, code in the Render method must be optimized. It doesn't do much good to reduce network through put and browser rendering time if we're going to spend more time on the server whittling down some small number of bytes. The best that I can shave off so far is about 30k from pages of less than 200k in size. It's not worth it to lose time with a 15% size reduction.
Thanks.
Please do not refer me to CodeProject, StackOverflow, or other googled resources unless you're sure something works. Many blogs and forum postings imply have wrong and/or incomplete info. Regular expressions are often cited but frequently wrong. I'm looking for code that people are actually using with Telerik RadControls for ASP.NET Ajax. With this, I and others may be able to improve upon it - but we need a better base than some unknown code that someone simply found somewhere on the net.
On the flip-side of this, code in the Render method must be optimized. It doesn't do much good to reduce network through put and browser rendering time if we're going to spend more time on the server whittling down some small number of bytes. The best that I can shave off so far is about 30k from pages of less than 200k in size. It's not worth it to lose time with a 15% size reduction.
Thanks.
5 Answers, 1 is accepted
0
Hi TonyG,
Indeed, using the RadScriptManager and RadStyleSheetManager controls enable you to easily combine in to a single link all of the JavaScript and CSS links required by the RadControls. Note that combining many links for CSS and JavaScript in to a single request can significantly improve your page load time by reducing the number of round-trip requests your page makes when it loads. Also the script and css files of the RadControls are with optimized size themselves.
Other optimizing techniques for instance are:
- using RadCompression
- enabling Telerik CDN support
And for more suggestions, check out this article.
Greetings,
Iana
the Telerik team
Indeed, using the RadScriptManager and RadStyleSheetManager controls enable you to easily combine in to a single link all of the JavaScript and CSS links required by the RadControls. Note that combining many links for CSS and JavaScript in to a single request can significantly improve your page load time by reducing the number of round-trip requests your page makes when it loads. Also the script and css files of the RadControls are with optimized size themselves.
Other optimizing techniques for instance are:
- using RadCompression
- enabling Telerik CDN support
And for more suggestions, check out this article.
Greetings,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0

TonyG
Top achievements
Rank 1
answered on 30 Jul 2010, 07:46 PM
All of that is accurate and good information but it doesn't address my primary query.
Yes, we can compress the page/code to reduce the data on the wire, but when the page gets to the client it often deflates into a lot of whitespace and other waste which must be parsed on the client. It would be better to reduce the bulk on the server, so that we transport even less, and so that there is less for the client to render.
I'm looking for a way to remove excessive whitespace:
- At the beginning of lines (regex "^/s+<")
- Between tags: ("//.+>/s+<")
- Within tags: (">/s+.+<")
(I don't recall the regex I've tried yet, that's just off the top of my head and almost certainly wrong.)
There are also redundant tag terminators, like <img ...></img> where <img /> would be better. And I'm sure there are many other tricks that we can employ.
The problem is that attempts to reduce whitespace in HTML also affect the processing of Telerik scripts. It's easy to reduce page size by as much as 15% or a bit more, but there is the "random" chance that any given postback may fail because a script is going to trip on this.
I'm looking for an ongoing discussion where we can work out safe optimizations that will not haunt us later, and which yield a reasonable benefit compared to the processing required. I can provide some code here as a base but I'm hesitent to post what doesn't work. I'd rather hope to find someone who has done this who will post what does work.
Thanks.
Yes, we can compress the page/code to reduce the data on the wire, but when the page gets to the client it often deflates into a lot of whitespace and other waste which must be parsed on the client. It would be better to reduce the bulk on the server, so that we transport even less, and so that there is less for the client to render.
I'm looking for a way to remove excessive whitespace:
- At the beginning of lines (regex "^/s+<")
- Between tags: ("//.+>/s+<")
- Within tags: (">/s+.+<")
(I don't recall the regex I've tried yet, that's just off the top of my head and almost certainly wrong.)
There are also redundant tag terminators, like <img ...></img> where <img /> would be better. And I'm sure there are many other tricks that we can employ.
The problem is that attempts to reduce whitespace in HTML also affect the processing of Telerik scripts. It's easy to reduce page size by as much as 15% or a bit more, but there is the "random" chance that any given postback may fail because a script is going to trip on this.
I'm looking for an ongoing discussion where we can work out safe optimizations that will not haunt us later, and which yield a reasonable benefit compared to the processing required. I can provide some code here as a base but I'm hesitent to post what doesn't work. I'd rather hope to find someone who has done this who will post what does work.
Thanks.
0
Hello Tony,
Combining many links JavaScript in to a single request can significantly improve your page load time. Merely the client scripts for the controls you use on the respective page will be registered and downloaded by the browser. In order to combine the scripts of several RadControls, consider utilizing our RadScriptManager which replaces the regular MS ScriptManager control.
You may also refer to the separate nodes in the online examples or chapters in the documentation concerning the same subject:
http://demos.telerik.com/aspnet-ajax/controls/examples/default/defaultcs.aspx
http://www.telerik.com/help/aspnet-ajax/introduction.html
All the best,
Pavlina
the Telerik team
Combining many links JavaScript in to a single request can significantly improve your page load time. Merely the client scripts for the controls you use on the respective page will be registered and downloaded by the browser. In order to combine the scripts of several RadControls, consider utilizing our RadScriptManager which replaces the regular MS ScriptManager control.
You may also refer to the separate nodes in the online examples or chapters in the documentation concerning the same subject:
http://demos.telerik.com/aspnet-ajax/controls/examples/default/defaultcs.aspx
http://www.telerik.com/help/aspnet-ajax/introduction.html
All the best,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0

Orin Book
Top achievements
Rank 1
answered on 03 Mar 2011, 05:45 PM
Telerik support did not answer the question. Will Telerik reduce whitespace in its generated code? The question is very specific and gives examples of where Telerik can reduce code bloat when user renders page. CDN and script combining is not the answer. I would recommend that Telerik establish a QA section that single purpose is practices to reduce code bloat, whitespace, faster rendering, better caching. More and more developers rely on Telerik and need Telerik to attack this issue. Fast rendering, improved page speed and YSlow scores.
0
Hi Orin,
We are always striving to deliver rich set of features for our controls without compromising their overall performance. This would be our ultimate goal for the future versions of the RadControls for ASP.NET AJAX suite and you can count on that.
All the best,
Pavlina
the Telerik team
We are always striving to deliver rich set of features for our controls without compromising their overall performance. This would be our ultimate goal for the future versions of the RadControls for ASP.NET AJAX suite and you can count on that.
All the best,
Pavlina
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!