<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Runtime Debugger - kannan M ambadi's blog : Skins</title><link>http://weblogs.asp.net/kannanambadi/archive/tags/Skins/default.aspx</link><description>Tags: Skins</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Improve ASPX web page performance by combining Skin &amp; CSS</title><link>http://weblogs.asp.net/kannanambadi/archive/2009/06/22/improve-aspx-page-performance-by-reducing-http-response-size-by-combining-skin-amp-css.aspx</link><pubDate>Mon, 22 Jun 2009 02:57:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7131770</guid><dc:creator>kannan.ambadi</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/kannanambadi/rsscomments.aspx?PostID=7131770</wfw:commentRss><comments>http://weblogs.asp.net/kannanambadi/archive/2009/06/22/improve-aspx-page-performance-by-reducing-http-response-size-by-combining-skin-amp-css.aspx#comments</comments><description>&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; There has been numerous discussions happened on web site performance, ranging from UI design to Site &lt;strike&gt;H&lt;/strike&gt;osting. Out of this, one of the important step is, to reduce the size of Http Response size. Optimizing Http Response will considerably reduce the page loading time at the browser. There are many ways to create optimized HTML markups to improve client-side performance. I would like to explain one such a way of designing web page. The Loading time factor will mainly depends on the web page size that is going to download at the client's browser. In order to achieve this as a web developer, you will have to work on the following things at least.&lt;i&gt; &lt;/i&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;HTML -&amp;gt; Use &lt;a href="http://en.wikipedia.org/wiki/XHTML" mce_href="http://en.wikipedia.org/wiki/XHTML" target="_blank"&gt;XHTML&lt;/a&gt; markups with CSS always rather than using HTML tables with inline HTML style attributes unless it is required. &lt;/li&gt;    &lt;li&gt;CSS -&amp;gt; Keep all your style definitions in an external&amp;nbsp; stylesheet. It will make the page source clean and also reduce the Http Requests by caching these files at the client machine. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;I don't want to discuss about JavaScript, since it might be deviating from the topic. As my title says, we can reduce the HTTP Response size by combining those two factors mentioned above with the help of Asp.Net Skin files. &lt;/p&gt;  &lt;p&gt;As you know, Asp.Net 2.0 has introduced a new feature called &lt;a href="http://msdn.microsoft.com/en-us/library/ykzx33wh.aspx" mce_href="http://msdn.microsoft.com/en-us/library/ykzx33wh.aspx" target="_blank"&gt;Themes&lt;/a&gt; which helps to achieve consistent look and feel for websites. Themes may contain Skin files, CSS files, images etc. A Skin file is nothing but extensions of CSS definitions for the Asp.Net server controls. Themes and skins enables to handle style attributes from Application level to Control level. Skins are mainly used for Web controls such as Label, Button etc. There are two types of skin file, Default skin - which applies same style for all the controls of same type and Named Skin - which possess a SkinID property by which we can apply Style to the control's skinId. Here is an example for Skin file: &lt;/p&gt;  &lt;p&gt;&lt;font color="#ff0000"&gt;&lt;font color="#800000"&gt;&amp;lt;asp:Button&amp;nbsp; &lt;/font&gt;SkinID&lt;font color="#0000ff"&gt;="buttonStyle"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; runat&lt;font color="#0000ff"&gt;="server"&lt;/font&gt; &lt;/font&gt;BackColor&lt;font color="#0000ff"&gt;="#2E132D"&lt;/font&gt; BorderColor&lt;font color="#0000ff"&gt;="#507CD1"&lt;/font&gt;&amp;nbsp; Height="25px" Width="120px"       &lt;br&gt;BorderStyle='Solid' BorderWidth='1px' Font-Names='Verdana' Font-Size='11px' ForeColor='White' Font-Bold='true' /&amp;gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;The main disadvantage on Skin file is, it renders the pre-defined style definitions as inline HTML style attributes attached with the control to which skin is applied. Lets see the skin given above, it renders into the browser as follows &lt;/p&gt;  &lt;p&gt;&lt;i&gt;&amp;lt;input type='submit' style='width:120px;height:25px;font-weight:bold;font-size:11px;font-family:Verdana;color:White;border-width:1px;border-style:Solid;border-color:#507CD1;background-color:#2E132D; /&amp;gt;&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;These chunks of HTML markups generates every time when the associated web control renders into the browser. Even though the ASPX part looks neat and clean, the HTML markups rendered at the browser may reminds the old &lt;a href="http://en.wikipedia.org/wiki/Web_1.0" mce_href="http://en.wikipedia.org/wiki/Web_1.0" target="_blank"&gt;Web 1.0&lt;/a&gt; page(ie: html tags without CSS) and also results in large size of HTTP Response.&amp;nbsp; Such pages will definitely affect the performance of the website. How can you avoid such scenario? Does it mean skin files are not good at website development? Will Css alone provide better performance?&amp;nbsp; I would say no and definitely continue with skin files, but combined with CSS. In such case, we'll be writing most of the style definitions in CSS classes and link that class to skin by using a skin control property called CssClass. This time, the above skin style will look like as &lt;/p&gt; &lt;font color="#ff0000"&gt;&lt;font color="#800000"&gt;&amp;lt;asp:Button&amp;nbsp; &lt;/font&gt;SkinID&lt;font color="#0000ff"&gt;="buttonStyle" &lt;/font&gt;runat&lt;font color="#0000ff"&gt;="server"&lt;/font&gt; CssClass&lt;font color="#0000ff"&gt;="normalButton"&lt;/font&gt; /&amp;gt;&lt;/font&gt;   &lt;p&gt;and it will render as &lt;/p&gt;  &lt;p&gt;&lt;i&gt;&amp;lt;input type='submit' &lt;/i&gt;class='normalButton' /&amp;gt;&lt;/p&gt;  &lt;p&gt;Did you see any difference? The chunks of HTML markups are gone!!!....The page size has reduced without removing skins, but by moving all style definitions into an external CSS file.&lt;/p&gt;    &lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:874b87a3-b151-4f15-b108-94e32784bb19" style="margin: 0px; padding: 0px; display: inline;"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/Asp.Net" mce_href="http://technorati.com/tags/Asp.Net" rel="tag"&gt;Asp.Net&lt;/a&gt;,&lt;a href="http://technorati.com/tags/HTML" mce_href="http://technorati.com/tags/HTML" rel="tag"&gt;HTML&lt;/a&gt;,&lt;a href="http://technorati.com/tags/CSS" mce_href="http://technorati.com/tags/CSS" rel="tag"&gt;CSS&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Themes" mce_href="http://technorati.com/tags/Themes" rel="tag"&gt;Themes&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Skins" mce_href="http://technorati.com/tags/Skins" rel="tag"&gt;Skins&lt;/a&gt;,&lt;a href="http://technorati.com/tags/HTTP%20Response" mce_href="http://technorati.com/tags/HTTP%20Response" rel="tag"&gt;HTTP Response&lt;/a&gt;,&lt;a href="http://technorati.com/tags/StyleSheet" mce_href="http://technorati.com/tags/StyleSheet" rel="tag"&gt;StyleSheet&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Page%20Performance" mce_href="http://technorati.com/tags/Page%20Performance" rel="tag"&gt;Page Performance&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Loading%20Time" mce_href="http://technorati.com/tags/Loading%20Time" rel="tag"&gt;Loading Time&lt;/a&gt;&lt;/div&gt;&lt;font color="#ff0000"&gt;&lt;br&gt;&lt;/font&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7131770" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/Asp.Net/default.aspx">Asp.Net</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/Response/default.aspx">Response</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/C_2300_+2.0/default.aspx">C# 2.0</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/microsoft/default.aspx">microsoft</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/visual+studio/default.aspx">visual studio</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/Themes/default.aspx">Themes</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/StyleSheet/default.aspx">StyleSheet</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/Asp.Net+2.0/default.aspx">Asp.Net 2.0</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/CSS/default.aspx">CSS</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/HTML/default.aspx">HTML</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/.NET+3.5/default.aspx">.NET 3.5</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/.NET+2.0/default.aspx">.NET 2.0</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/ASP.NET+3.5/default.aspx">ASP.NET 3.5</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/.net+development/default.aspx">.net development</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/.NET+Framework/default.aspx">.NET Framework</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/Web+2.0/default.aspx">Web 2.0</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/Web+Development/default.aspx">Web Development</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/Tools/default.aspx">Tools</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/Performance/default.aspx">Performance</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/Code+Perfromance/default.aspx">Code Perfromance</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/Skins/default.aspx">Skins</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/Web/default.aspx">Web</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/Tips/default.aspx">Tips</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/General+Software+Development/default.aspx">General Software Development</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/Tips+and+Tricks/default.aspx">Tips and Tricks</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/ASPX+Page+Performance/default.aspx">ASPX Page Performance</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/Software+Development/default.aspx">Software Development</category></item></channel></rss>