<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>Welcome to GlobalLogic Blogs &#187; Web 2.0</title>
	<atom:link href="http://blogs.globallogic.com/category/web-20/feed" rel="self" type="application/rss+xml" />
	<link>http://blogs.globallogic.com</link>
	<description>Exponential Innovation</description>
	<pubDate>Mon, 30 Jan 2012 06:04:14 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
	<language>en</language>
			<item>
		<title>HTML5 Mobile App Frame Works</title>
		<link>http://blogs.globallogic.com/html5-mobile-app-frame-works</link>
		<comments>http://blogs.globallogic.com/html5-mobile-app-frame-works#comments</comments>
		<pubDate>Thu, 15 Dec 2011 12:27:08 +0000</pubDate>
		<dc:creator>ninad.pandey</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<category><![CDATA[Web 2.0]]></category>

		<guid isPermaLink="false">http://blogs.globallogic.com/?p=1770</guid>
		<description><![CDATA[All of us are aware of the fact that the Mobile web apps concept is gearing up very rapidly. In-fact many mobile web applications have rolled out and are already being used by people across the globe. Recent mobile devices are having good processing power and capabilities. Specifically, the WebKit based browsers are more powerful [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal">All of us are aware of the fact that the Mobile web apps concept is gearing up very rapidly. In-fact many mobile web applications have rolled out and are already being used by people across the globe. Recent mobile devices are having good processing power and capabilities. Specifically, the WebKit based browsers are more powerful and capable. These WebKit browsers are almost at par with the desktop browsers and have capability of rendering complex web contents.</p>
<p class="MsoNormal"><strong>Native Mobile applications</strong></p>
<p class="MsoNormal">It is needless to say, that a native mobile application is created in the respective programming language/SDK for the platform like Android and IOS. Native application normally has following two plus points points:</p>
<ol>
<li>Provides seamless user experience. The native applications normally have the look and feel same as that of other platform applications.</li>
<li>Transition and animation effects while navigating within the application.</li>
<li>Access to devices resources/features like SDCard and camera</li>
</ol>
<p><strong>Mobile Web Application</strong></p>
<p>Mobile web applications are created using the web technologies like HTML5, JavaScript and CSS3. The mobile web application can be available in either methods as below:</p>
<ol>
<li>A web site optimized for mobile device and hosted on a web server. Which is accessed using the web browser on the device</li>
<li>A native/hybrid application created using PhoneGap or by embedding the WebView in a application</li>
</ol>
<p>In both the case, the mobile web apps needs to have</p>
<ol>
<li>Look and feel in sync with the platform being used. This would provide a seamless user experience</li>
<li>Mobile optimized view and touch support</li>
<li>Transitions and animations during navigation</li>
</ol>
<p>The native look and feel and transition requirements can be addressed by using available HTML5 Mobile frameworks explained next.</p>
<p><strong>HTML5 Mobile App Frameworks</strong></p>
<p>In recent years w/ the advent of HTML5, many HTML5 mobile app frameworks are available. These frameworks provides features like:</p>
<ol>
<li>Native Look &amp; Feel</li>
<li>Animation</li>
<li>Transitions</li>
<li>2D Drawing using Canvas</li>
<li>3D drawing using Web GL</li>
</ol>
<p>These frameworks can be used to create a mobile web site as well a native (Hybrid) mobile application. These frameworks are also compatible with PhoneGap and Appmobi. With the help of the HTML5 mobile app frameworks it is possible to have a native look and feel at the same time leveraging the HTML5 features like:</p>
<ol>
<li>Geo location</li>
<li>Local Storage</li>
<li>Web Sockets</li>
<li>Audio/Video API</li>
</ol>
<p>In the crowd of existing HTML5 Mobile App framework, I got a chance to explore following frameworks</p>
<p><strong>JQuery Mobile</strong></p>
<p>JQuery mobile is cross platform &amp; cross device mobile Web App framework. It can be used to create a mobile web site, hosted on a web server as well as to create a native application using PhoneGap. It provides a unified user experience on the mobile devices. It has quite good number of widgets like Lists, Form elements, switches along with page animations and transitions.</p>
<p>Recently JQuery Mobile released its Final version 1.0. Compared to others it is a new player in the market but looks promising. It is based on the popular JQuery platform and is lightweight. So a person who is familiar is with JQuery, will find it bit easy to use.  It provides a flexible, easily themeable design which can be customized per the requirement</p>
<p>It does not provide any abstraction for HTML5/JavaScript APIs. One has to explicitly use the HTML5/JavaScript API. It also works well with PhoneGap and AppMobi. It makes use declarative HTML mark-up which can be updated at run time using DOM manipulation</p>
<p>It supports following platforms:</p>
<ul>
<li>IOS</li>
<li>Android</li>
<li>BlackBerry</li>
<li>Windows Phone</li>
<li>Symbian</li>
</ul>
<p><strong>Dojo Mobile</strong></p>
<p>Dojo Mobile is a HTML5 mobile JavaScript framework that enables rapid development of mobile web applications with a native look and feel on modern webkit-enabled mobile devices such as iPhone, iPod Touch, iPad, Android and RIM smartphones and tablets. It is based on the popular Dojo library already available for the web</p>
<p>It provides several lightweight widgets (views, buttons, lists, etc.) that look and act like those found on the iOS and Android native interfaces. The View widget defines a single page in your application. One can add multiple views to the application and  use the provided transitions (flip, fade, and slide) to move between the views.</p>
<p>The current version of dojo is 1.6 and 1.7 is scheduled for release.</p>
<p>Dojo Mobile also provides features like:</p>
<ul>
<li>Gauges</li>
<li>Chart widget</li>
</ul>
<p>Applications that run on an Android have a distinctly different look than iPhone applications. Dojo mobile provides CSS style-sheets for both the Android and iPhone. One can  build a separate application for each device, or use JavaScript at run time, to determine the type of device the application is running on and then use the appropriate style-sheet.</p>
<p>Dojo Mobile is PhoneGap ready. So it can be used to create native application and publish to market place.<br />
It provides both declarative and dynamic UI. The widget can be either defined using HTML/JSON or can be created dynamically</p>
<p><strong>Sencha Touch</strong></p>
<p>Sencha Touch is based on the popular Ext JavaScript Framework. It is optimized and scaled down for the mobile device usage. It leverages HTML5, CSS3, and Javascript for the highest level of power, flexibility, and optimization.</p>
<p>It makes specific use of HTML5 to deliver components like Audio and Video. It provides abstraction API for leveraging HTML5 storage features like LocalStorage, SessionStorage etc.</p>
<p>Sencha Touch is compatible with Phonegap using which it can be used to create native mobile applications.</p>
<p>It makes us of minimal HTML code and renders its own DOM based on the objects created using the JavaScript. For some this may be a dis-appointing factor, since it gives a less webby experience while coding</p>
<p>As compared to the counter parts, Sencha Touch is more extensive in term of UI components, transitions/animations and explicit iPad support. It has incredible support for storage and data binding facilities using JSON and HTML5 offline storage, and more.</p>
<p>It also performs better than JQuery Mobile except the initial loading time.</p>
<p>Currently it supports following platforms:</p>
<ul>
<li>Android</li>
<li>iOS</li>
<li>Blackberry</li>
</ul>
<p>Sencha also provides a Native Packaging for Android and IOS. It can be used to create .APK and .APP file. For the native packaging SenchaSDKTools needs to be downloaded and installed</p>
<p>In addition to these frameworks, there are other frameworks available. Will cover the other frameworks later</p>
<p class="MsoNormal">
<p class="MsoNormal">
]]></content:encoded>
			<wfw:commentRss>http://blogs.globallogic.com/html5-mobile-app-frame-works/feed</wfw:commentRss>
		</item>
		<item>
		<title>Mobile Web and HTML 5</title>
		<link>http://blogs.globallogic.com/mobile-web-and-html-5</link>
		<comments>http://blogs.globallogic.com/mobile-web-and-html-5#comments</comments>
		<pubDate>Sat, 08 Oct 2011 17:51:38 +0000</pubDate>
		<dc:creator>ninad.pandey</dc:creator>
		
		<category><![CDATA[Cloud]]></category>

		<category><![CDATA[Global Product Development]]></category>

		<category><![CDATA[Marketing]]></category>

		<category><![CDATA[Technology]]></category>

		<category><![CDATA[Web 2.0]]></category>

		<guid isPermaLink="false">http://blogs.globallogic.com/?p=1636</guid>
		<description><![CDATA[In recent past, I came across requirements about creating mobile application for IPhone and Android platform. One of the obvious choices was to create a native application for IPhone and Android respectively.
After understanding the requirement, it was learnt that the application doesn’t need to access any of the native feature of mobile device like camera, [...]]]></description>
			<content:encoded><![CDATA[<p>In recent past, I came across requirements about creating mobile application for IPhone and Android platform. One of the obvious choices was to create a native application for IPhone and Android respectively.</p>
<p>After understanding the requirement, it was learnt that the application doesn’t need to access any of the native feature of mobile device like camera, accelerometer. In other words the application was a data driven application having rich user interface. It triggered the thought!!! Why not have Mobile Web Application for this?<br />
<strong></strong></p>
<p><strong>What is Mobile Web Application?</strong><br />
Mobile Web Application is web application, optimized to run in mobile device web browser. Some of the parameters under consideration are:</p>
<ul>
<li>Screen size</li>
<li>Bandwidth</li>
<li>Device orientation</li>
<li>Native user interface</li>
</ul>
<p>Present day mobile web browsers contained by smart phones like IPhone and Android can show almost every website that we can open on desktop browser.<br />
<strong>Advantages</strong><br />
One of the biggest advantages of Mobile Web App is, it can be uses over the variety of smart phones. If any customization is required for specific mobile device model, then it can be done on the server side. There is no need to create ports for different mobile devices.<br />
In case of there is any update in the application, then the web server contents only needs to be updated. The mobile client will always get the updated contents.</p>
<p><strong>Conventional Mobile Web App</strong></p>
<p>Conventional mobile web can be created in any web platform like PHP, ASP.NET. It essentially consists of a home page which uses HTML mark-up along with CSS and javasript. Mobile user starts the web browser and hits the home page and starts using the application. For each such page, the server sends and HTML mark-up and images to have a decent user interface. One drawback here is the look and feel. Once the user starts the web application, he/she gets an off-deck user experience. The mobile web application look and feel in most of the cases is very different from the mobile device native user interface.</p>
<p><strong>Leveraging HTML 5 &amp; CSS3</strong></p>
<p>HTML 5 is fast catching up. W3C has already created the draft for HTML 5 and CSS3 standards. Popular desktop browser like Chrome, Firefox 4.0 and Opera 9 supports most of HTML5 and CSS3 standards.<br />
Good news is, IPhone mobile safari and Android device web browser also supports most of the HTML 5 and CSS3 features. With support for CSS3 and HTML 5, the developers get extra arsenals for creating more sophisticated mobile web applications<br />
<strong></strong></p>
<p><strong>Native Look &amp; Feel using CSS3</strong></p>
<p>With the use of CSS3 it is possible to have native look &amp; feel for IPhone and Android devices. Some of the CSS3 features are:</p>
<ul>
<li>Text effects, Gradients</li>
<li>2D transformation</li>
<li>3D transformation</li>
<li>Transitions</li>
<li>Animations</li>
</ul>
<p>With above feature we can add the animation and transition effect to mobile web applications similar to what IPhone and Android devices provide. Due to support for gradient and text effects in CSS3, we can minimize use of images. This also helps further to reduce the page pay load</p>
<p><strong>Test Web page without any specific CSS</strong>.</p>
<p><a href="http://blogs.globallogic.com/wp-content/uploads/2011/10/site_wo_style.jpg"><img class="alignnone size-medium wp-image-1645" src="http://blogs.globallogic.com/wp-content/uploads/2011/10/site_wo_style-300x267.jpg" alt="" width="300" height="267" /></a></p>
<p><strong>Test Web page in Android emulator after applying CSS<br />
</strong></p>
<p><a href="http://blogs.globallogic.com/wp-content/uploads/2011/10/android_style1.jpg"><img class="alignnone size-medium wp-image-1647" src="http://blogs.globallogic.com/wp-content/uploads/2011/10/android_style1-300x271.jpg" alt="" width="300" height="271" /></a></p>
<p><strong>Test Web page in IPhone emulator after applying CSS</strong></p>
<p><a href="http://blogs.globallogic.com/wp-content/uploads/2011/10/iphone.jpg"><img class="alignnone size-medium wp-image-1649" src="http://blogs.globallogic.com/wp-content/uploads/2011/10/iphone-300x280.jpg" alt="" width="300" height="280" /></a></p>
<p><strong>HTML 5 features</strong></p>
<p>HTML 5 provides many new features as compared to HTML 4. IPhone and Android mobile web browsers now support most of the HTML 5 features.  Some of the important HTML 5 features are:</p>
<ul>
<li>Local Web storage. Can be used to store the intermediate data locally and when required the data can be saved to cloud or the web server</li>
<li>Access to Geolocation. Can be used to location based application</li>
<li>Audio API. Can be used to control and play audio</li>
<li>Video API</li>
<li>Canvas support. A 2D drawing mechanism.</li>
<li>Web Sockets. Real time application</li>
</ul>
<p><strong>Full Screen Browser Or Native application with embedded web browser (Hybrid)?</strong></p>
<p>The most common way to start a Mobile Web Application on mobile device is to start the web browser and type the application URL.  We can use JavaScript to set the web browser to full screen mode. For some people still this may be dislike.<br />
For such, we can have a native device application. This application then embeds the Web view. Of course, this device application needs to be created to all supported platform. The user downloads this native application from app store. When launched, it displays the embedded web view in full screen view and hits the application home URL. This way the user has a seamless user experience. With this hybrid one can also provide a mechanism to intercept the events in the web view. For example we can intercept click events for all hyperlinks in the view and then may call some native function using the device specific language.</p>
<p><strong>Accessing phone&#8217;s native features</strong></p>
<p>There are many instances, in which we may need to access the native phone features like Geo-location, accelerometer. At present not all native phone features can be accessed using JavaScript API from HTML5. Unfortunately not all native features can be access using the JavaScript API. Currently JavaScript APIs are available to access the Geolocation and Address book.<br />
For other features like camera, accelerometer we need to use some bridge. Most common way is to use PhoneGap. It provides an interface to access the native features of mobile devices. It is available for IPhone, Android and other smart phones</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.globallogic.com/mobile-web-and-html-5/feed</wfw:commentRss>
		</item>
		<item>
		<title>Introduction to Lucene</title>
		<link>http://blogs.globallogic.com/introduction-to-lucene</link>
		<comments>http://blogs.globallogic.com/introduction-to-lucene#comments</comments>
		<pubDate>Tue, 30 Aug 2011 11:51:08 +0000</pubDate>
		<dc:creator>Rajender Aggarwal</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<category><![CDATA[Web 2.0]]></category>

		<category><![CDATA[full text search]]></category>

		<category><![CDATA[lucene]]></category>

		<guid isPermaLink="false">http://blogs.globallogic.com/?p=1394</guid>
		<description><![CDATA[Apache Lucene is an open-source, high-performance, full-featured text search engine written entirely in Java. It is a technology suitable for nearly any application that requires full-text search, especially cross-platform. Lucene collects, parses, and indexes (or stores) data to facilitate fast and accurate information retrieval. ]]></description>
			<content:encoded><![CDATA[<p>Apache <a href="http://lucene.apache.org/java/docs/index.html">Lucene</a> is an open-source, high-performance, full-featured text search engine  written entirely in Java. It is a technology suitable for nearly any  application that requires full-text search, especially cross-platform.  Lucene collects, parses, and indexes (or stores) data to facilitate fast  and accurate information retrieval.</p>
<h3><strong><span style="bold;">Indexing Basics</span></strong></h3>
<p>The purpose of storing an index is to optimize speed and performance  in finding relevant documents for a search query. Without an index, the  search engine would scan every document in the corpus, which would  require considerable time and computing power. For example, while an  index of 10,000 documents can be queried within milliseconds, a  sequential scan of every word in 10,000 large documents could take  hours. The additional computer storage required to store the index, as  well as the considerable increase in the time required for an update to  take place, are traded off for the time saved during information  retrieval.</p>
<p>Lucene stores the data in the form of an inverted index. This index  can only determine whether a word exists within a particular  document,  since it stores no information regarding the frequency and  position of  the word. Such an index determines which documents match a query but  does not rank matched documents. Typically, position information and  frequency is used to help in ranking the relevance of the documents.</p>
<p>Lucene index is built over an implementation of the Directory class. Lucene supports multiple Directory implementations :</p>
<ul>
<li>RAMDirectory: Implementation of RAM-based indices.</li>
<li>FSDirectory: Implementation of an index as a single file. Indices is stored file system. Some part of is kept in Cache.</li>
<li>DbDirectory: Implementation indices stored in a database, via JDBC.</li>
</ul>
<h3><strong><span style="bold;">Lucene Concepts</span></strong></h3>
<ul>
<li><strong><span style="bold;">Term </span></strong>: A Term  represents a word from text.  This is the unit of search.  It is    composed of two elements, the text of the word, as a string, and the  name of   the field that the text occured in, an interned string.     Note that terms may represent more than words from text fields, but also    things like dates, email addresses, URLs, etc.</li>
<li><strong><span style="bold;">Document</span> </strong>: Documents are the unit of indexing and search.   A Document is a set  of fields.  Each field has a name and a textual value. Thus each  document  should typically contain one or more stored fields which  uniquely identify  it.</li>
<li><strong><span style="bold;">Field</span> </strong>: A field is a section of a Document.  Each field has two parts, a name  and a   value.  Values may be free text, provided as a String or as a  Reader, or they   may be atomic keywords, which are not further  processed.  Such keywords may   be used to represent dates, URLs, etc.   Fields are optionally stored in the   index, so that they may be  returned with hits on the document.</li>
<li><strong><span style="bold;">Analyzer</span> </strong>:An Analyzer is used to analyze text.  It thus represents a   policy  for extracting index terms from text. Typical implementations first  build a Tokenizer, which breaks the stream of   characters tokens.  One  or more filters   then be applied.</li>
<li><strong><span style="bold;">Query</span> </strong>: Base for all queries. Various types of queries are:<br />
* TermQuery<br />
* BooleanQuery<br />
* WildcardQuery<br />
* PhraseQuery<br />
* PrefixQuery<br />
* MultiPhraseQuery<br />
* FuzzyQuery<br />
* TermRangeQuery<br />
* NumericRangeQuery</li>
</ul>
<h3><span style="bold;">Adding Data to Lucene Index</span></h3>
<p><span style="bold;"> </span> // Step 1: Instantiate the Directory, Analyzer and Index Writer.<br />
// Create instance of Directory where index files will be stored<br />
File indexDirectoryPath = new File(&#8221;C:\\temp\\index&#8221;);<br />
Directory fsDirectory = FSDirectory.open(indexDirectoryPath);</p>
<p>// Step 2: Create instance of analyzer, which will tokenize the input data<br />
Analyzer analyzer = new SimpleAnalyzer(Version.LUCENE_33);</p>
<p>//Step 3: Create a new index. Create instance of the IndexWriter<br />
IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_33, analyzer);<br />
conf.setMaxThreadStates(2);</p>
<p>IndexWriter indexWriter = new IndexWriter(fsDirectory, conf);</p>
<p>//Step 4: Prepare the data for indexing.<br />
String emailId = &#8220;testemail@mailinator.com&#8221;;<br />
String message = &#8220;This is a TEST message for indexing.&#8221;;</p>
<p>//Step 5: Wrap the data in the Fields and add them to a Document.<br />
Field emailIdField = new Field(&#8221;emailId&#8221;, emailId, Field.Store.YES, Field.Index.NOT_ANALYZED);<br />
Field messageField = new Field(&#8221;message&#8221;, message, Field.Store.YES, Field.Index.ANALYZED);<br />
Document doc = new Document();</p>
<p>// Step 6: Add these fields to a Lucene Document<br />
doc.add(emailIdField);<br />
doc.add(messageField);</p>
<p>//Step 7: Add this document to Lucene Index.<br />
indexWriter.addDocument(doc);</p>
<p>//Step 8: Optimize Lucene Index.<br />
indexWriter.optimize();</p>
<p>//Step 9. Close Lucene Index.<br />
indexWriter.close();</p>
<p>Download <a href="http://www.getopt.org/luke/">Luke </a>and try some of the queries on your indexes by changing the Analyzers. The tool can also be used to view and modify indexes.</p>
<p><span style="bold;">Index Optimization</span> :  Requests an &#8220;optimize&#8221; operation on an index, priming the index for the  fastest available search. Traditionally this has meant merging all  segments into a single segment as is done in the default merge policy,  but individual merge policies may implement optimize in different ways.<br />
It is recommended that this method be called upon completion of  indexing. In environments with frequent updates, optimize is best done  during low volume times, if at all.</p>
<h3><strong><span style="bold;">Querying Index</span></strong></h3>
<p><span style="bold;"> </span><span style="italic;"> String querystr = &#8220;message&#8221;;</span></p>
<p>//Step 1: Instantiate the Analyzer<br />
Analyzer simpleAnalyzer = new SimpleAnalyzer(Version.LUCENE_33);</p>
<p>//Step 2: Create Query<br />
Query q = new QueryParser(Version.LUCENE_33, &#8220;message&#8221;, simpleAnalyzer).parse(querystr);<br />
int hitsPerPage = 20;</p>
<p>//Step 3: Instantiate the Searcher<br />
File indexDirectoryPath = new File(&#8221;C:\\temp\\index&#8221;);<br />
Directory fsDirectory = FSDirectory.open(indexDirectoryPath);<br />
IndexSearcher indexSearcher= new IndexSearcher(fsDirectory);<br />
TopScoreDocCollector collector = TopScoreDocCollector.create(hitsPerPage, true);</p>
<p>//Step 4: Perform Search and collect results<br />
indexSearcher.search(q, collector);<br />
ScoreDoc[] scoreDosArray = collector.topDocs().scoreDocs;</p>
<p>// Step 5: Retrieve the matched document and show relevant details<br />
for(ScoreDoc scoredoc : scoreDosArray){<br />
<span style="italic;"> </span><span style="italic;"> </span><span style="italic;"> </span><span style="italic;"> </span><span style="italic;"> </span><span style="italic;">Document doc = indexSearcher.doc(scoredoc.doc);<br />
</span><span style="italic;"> </span><span style="italic;"> </span><span style="italic;"> </span><span style="italic;"> </span><span style="italic;"> </span><span style="italic;">System.out.println(&#8221;emailId["+ doc.getFieldable("emailId").stringValue()+"]&#8220;);<br />
</span><span style="italic;"> </span><span style="italic;"> </span><span style="italic;"> </span><span style="italic;"> </span><span style="italic;"> </span><span style="italic;">System.out.println(&#8221;message["+ doc.getFieldable("message").stringValue()+"]&#8220;);<br />
}</span></p>
<p>//Step 6: Close Lucene Index Searcher.<br />
indexSearcher.close();</p>
<p>Further, Lucene can be integrated with Hibernate framework to help parse and index data. More on this in my next post.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.globallogic.com/introduction-to-lucene/feed</wfw:commentRss>
		</item>
		<item>
		<title>Cascading Style Sheet (CSS) – What must web developer know?</title>
		<link>http://blogs.globallogic.com/cascading-style-sheet-css-%e2%80%93-what-must-web-developer-know</link>
		<comments>http://blogs.globallogic.com/cascading-style-sheet-css-%e2%80%93-what-must-web-developer-know#comments</comments>
		<pubDate>Tue, 24 May 2011 16:52:47 +0000</pubDate>
		<dc:creator>dhejov</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<category><![CDATA[Web 2.0]]></category>

		<category><![CDATA[Box Model]]></category>

		<category><![CDATA[Cascade]]></category>

		<category><![CDATA[Cascading Style Sheet]]></category>

		<category><![CDATA[CSS]]></category>

		<category><![CDATA[CSS Selector]]></category>

		<category><![CDATA[Inheritance]]></category>

		<category><![CDATA[Selectoracle]]></category>

		<category><![CDATA[Specificity]]></category>

		<guid isPermaLink="false">http://blogs.globallogic.com/?p=1138</guid>
		<description><![CDATA[It is a general perspective that CSS is a designer stuff. IMHO this is not completely correct as having fundamental understanding of CSS and how it works is very important for every web developer. It not only helps you to improve your presentation skill but also improve your understanding of DOM and how to parse [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">It is a general perspective that CSS is a designer stuff. IMHO this is not completely correct as having fundamental understanding of CSS and how it works is very important for every web developer. It not only helps you to improve your presentation skill but also improve your understanding of DOM and how to parse the DOM.</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">Let us start by looking at the anatomy of a web page. Primarily web page has HTML, CSS and JavaScript or a more generic explanation will be:</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">A web page has:</span></span></p>
<p class="MsoListParagraphCxSpFirst" style="l4 level1 lfo1;"><span style="Symbol;"><span style="Ignore;"><span style="small;">·</span><span style="7pt &quot;Times New Roman&quot;;"> </span></span></span><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">Structure: HTML</span></span></p>
<p class="MsoListParagraphCxSpMiddle" style="l4 level1 lfo1;"><span style="Symbol;"><span style="Ignore;"><span style="small;">·</span><span style="7pt &quot;Times New Roman&quot;;"> </span></span></span><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">Presentation: CSS</span></span></p>
<p class="MsoListParagraphCxSpLast" style="l4 level1 lfo1;"><span style="Symbol;"><span style="Ignore;"><span style="small;">·</span><span style="7pt &quot;Times New Roman&quot;;"> </span></span></span><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">Behavior: JavaScript</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">We will be focusing on the presentation today. I don’t expect you to be an expert at the end of this blog but at least I would expect that you will be skilled or at least inspired to explore more into the world of presentation aspects of a web page.</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">What is CSS? (I know all of you would know the answer). As per Wikipedia definition of </span></span><a href="http://en.wikipedia.org/wiki/Cascading_Style_Sheets"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">CSS</span></span></a><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">:</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">“<strong><em>Cascading Style Sheets</em></strong><em> (<strong>CSS</strong>) is a </em></span></span><a title="Style sheet language" href="http://en.wikipedia.org/wiki/Style_sheet_language"><em><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">style sheet language</span></span></em></a><em><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;"> used to describe the </span></span></em><a title="Presentation semantics" href="http://en.wikipedia.org/wiki/Presentation_semantics"><em><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">presentation semantics</span></span></em></a><em><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;"> (the look and formatting) of a document written in a </span></span></em><a title="Markup language" href="http://en.wikipedia.org/wiki/Markup_language"><em><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">markup language</span></span></em></a><em><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">.”</span></span></em></p>
<h2><span style="medium;">Applying Stylesheets</span></h2>
<p class="MsoNormal" style="0in 0in 10pt;"> </p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">So how can we apply CSS on a web page? We have three option when it comes to applying CSS:</span></span></p>
<p class="MsoListParagraphCxSpFirst" style="l1 level1 lfo5;"><span style="'Microsoft Sans Serif';"><span style="Ignore;"><span style="small;">1.</span><span style="7pt &quot;Times New Roman&quot;;"> </span></span></span><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">Inline (Easy)</span></span></p>
<p class="MsoListParagraphCxSpMiddle" style="l1 level1 lfo5;"><span style="'Microsoft Sans Serif';"><span style="Ignore;"><span style="small;">2.</span><span style="7pt &quot;Times New Roman&quot;;"> </span></span></span><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">Embedded/</span></span><span style="9pt;">Internal </span><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">(Better)</span></span></p>
<p class="MsoListParagraphCxSpLast" style="l1 level1 lfo5;"><span style="'Microsoft Sans Serif';"><span style="Ignore;"><span style="small;">3.</span><span style="7pt &quot;Times New Roman&quot;;"> </span></span></span><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">External (Best)</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="small;"><strong><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;">Inline CSS</span></strong><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"> are applied using <strong><em>Style</em></strong> attribute of an HTML element. Below are few of the examples inline CSS:</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="yes;"><span style="small;">&lt;<span style="#a31515;">a</span> <span style="red;">style</span>=&#8221;<span style="red;">color</span>:red;<span style="red;">text-align</span>:left&#8221; <span style="red;">href</span>=&#8221;#&#8221;&gt;Hello World&lt;/<span style="#a31515;">a</span>&gt;</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="yes;"><span style="small;">&lt;<span style="#a31515;">p</span> <span style="red;">style</span>=&#8221;<span style="red;">margin-left</span>:10px;<span style="red;">margin-right</span>:20px&#8221;&gt;This is a paragraph&lt;/<span style="#a31515;">p</span>&gt;</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"> </p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">This is of course easy but we are now mixing the structure and presentation of a web page and should be avoided whenever if not always possible. In additional it also makes the web page less maintainable and will lead to code duplication.</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="small;"><strong><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;">Embedded/Internal CSS</span></strong><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"> are applied by adding &lt;<strong><em>style</em></strong>&gt; tag. Below is an example using embedded CSS:</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="small;"><span style="yes;">&lt;</span><span style="yes;">head<span style="blue;">&gt;</span></span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="yes;"><span style="small;"><span style="blue;">&lt;</span>style <span style="red;">type</span><span style="blue;">=&#8221;text/css&#8221;&gt;</span></span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="yes;"><span style="small;">a {<span style="red;">color</span>:<span style="blue;">red</span>;<span style="red;">text-align</span>:<span style="blue;">left</span>}</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="yes;"><span style="small;">p {<span style="red;">margin-left</span>:<span style="blue;">10px</span>;<span style="red;">margin-right</span>:<span style="blue;">20px</span>}</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="yes;"><span style="small;"><span style="blue;">&lt;/</span>style<span style="blue;">&gt;</span></span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="yes;"><span style="small;"><span style="blue;">&lt;/</span>head<span style="blue;">&gt;</span></span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"> </p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">This is a good approach during the development phase specially when you are trying to pick the right style for your web page.</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="small;"><strong><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;">External/Linked CSS</span></strong><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"> are applied using &lt;<strong><em>link</em></strong>&gt; tag which will contain the link to the CSS file in the <em>href</em> attribute.<span style="yes;"> </span>Although not very popular you can also use the <strong><em>@import</em></strong> statement within the style tag. Below is an example of using External CSS using &lt;<strong>link</strong>&gt; tag:</span></span></p>
<p class="MsoNormal" style="none;"><span style="yes;">&lt;</span><span style="yes;">head</span><span style="yes;">&gt;</span></p>
<p class="MsoNormal" style="none;"><span style="yes;"><span style="blue;">&lt;</span><span style="#a31515;">link</span> <span style="red;">rel</span><span style="blue;">=&#8221;stylesheet&#8221;</span> <span style="red;">type</span><span style="blue;">=&#8221;text/css&#8221;</span> <span style="red;">href</span><span style="blue;">=&#8221;BaseControlStyle.css&#8221;</span> <span style="blue;">/&gt;</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="yes;">&lt;/</span><span style="yes;">head</span><span style="yes;">&gt;</span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">This is the best option as it decouple the presentation from structure it also help to leverage the browser caching feature to improve the performance of the web page.</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">Although mentioned I would recommend avoiding usage of <strong><em>@import </em></strong>whenever possible as it kills the page performance. To read more on the performance impact of <strong><em>@import</em></strong> statement </span><a href="http://www.stevesouders.com/blog/2009/04/09/dont-use-import/"><span style="small;">here</span></a><span style="small;">.</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">There are other options when it comes to linking CSS which I would like to call uncommon or unconventional like using HTTP header which is explain in this </span></span><a href="http://www.w3.org/TR/html4/present/styles.html#h-14.6"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">article</span></span></a><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">.</span></span></p>
<h2><span style="medium;">Anatomy of CSS</span></h2>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">Simplest way to explain CSS anatomy to break it into 2 parts:</span></span></p>
<p class="MsoListParagraphCxSpFirst" style="l0 level1 lfo2;"><span style="'Microsoft Sans Serif';"><span style="Ignore;"><span style="small;">1.</span><span style="7pt &quot;Times New Roman&quot;;"> </span></span></span><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">Selector</span></span></p>
<p class="MsoListParagraphCxSpLast" style="l0 level1 lfo2;"><span style="'Microsoft Sans Serif';"><span style="Ignore;"><span style="small;">2.</span><span style="7pt &quot;Times New Roman&quot;;"> </span></span></span><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">Declaration (Properties and Values)</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="yes;"><span style="small;"><span style="yes;"><a href="http://blogs.globallogic.com/wp-content/uploads/2011/05/cssanatomy.jpg"><img class="alignnone size-medium wp-image-1139" src="http://blogs.globallogic.com/wp-content/uploads/2011/05/cssanatomy-300x181.jpg" alt="" width="300" height="181" /></a></span></span></span><span style="yes;"><span style="small;"> </span></span></p>
<p><span style="yes;"><span style="small;"><span style="small;"><span><strong></strong></span></span></span></span> </p>
<h3><span style="small;">CSS Selector</span></h3>
<p><span style="yes;"><span style="small;"><span style="small;"><span><strong>CSS Selector </strong></span><span style="yes;">is a pattern, which will be used to identify the element(s) on which the style will be applied.</span></span></span></span> </p>
<p> <span style="yes;"><span style="small;">Most commonly used selectors are:</span></span></p>
<p class="MsoListParagraphCxSpFirst" style="l3 level1 lfo3;"><span style="yes;"><span style="Ignore;"><span style="small;">1.</span><span style="7pt &quot;Times New Roman&quot;;"> </span></span></span><span style="yes;"><span style="small;">Type Selectors</span></span></p>
<p class="MsoListParagraphCxSpMiddle" style="l3 level1 lfo3;"><span style="yes;"><span style="Ignore;"><span style="small;">2.</span><span style="7pt &quot;Times New Roman&quot;;"> </span></span></span><span style="yes;"><span style="small;">Class Selectors</span></span></p>
<p class="MsoListParagraphCxSpMiddle" style="l3 level1 lfo3;"><span style="yes;"><span style="Ignore;"><span style="small;">3.</span><span style="7pt &quot;Times New Roman&quot;;"> </span></span></span><span style="yes;"><span style="small;">ID Selectors</span></span></p>
<p class="MsoListParagraphCxSpMiddle" style="l3 level1 lfo3;"><span style="yes;"><span style="Ignore;"><span style="small;">4.</span><span style="7pt &quot;Times New Roman&quot;;"> </span></span></span><span style="yes;"><span style="small;">Descentant Selectors</span></span></p>
<p class="MsoListParagraphCxSpLast" style="l3 level1 lfo3;"><span style="yes;"><span style="Ignore;"><span style="small;">5.</span><span style="7pt &quot;Times New Roman&quot;;"> </span></span></span><span style="yes;"><span style="small;">Pseudo classes</span></span></p>
<h4><span style="yes;"><em></em></span></h4>
<h4><span style="yes;"><em><span style="#4f81bd;"><span style="Cambria;"><span style="small;">Type Selectors</span></span></span></em></span></h4>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="yes;"><span style="small;">Select all elements of a particular type. For example:</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="yes;">h1</span><span style="yes;">{</span><span class="MsoHyperlink"><span style="166;"><span style="underline;"><span style="small;">declarations</span></span></span></span><span style="yes;">}</span><span style="yes;"><span style="small;"> – Will select all the H1 elements in the entire document</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="yes;">p</span><span style="yes;">{</span><span class="MsoHyperlink"><span style="166;"><span style="underline;"><span style="small;">declarations</span></span></span></span><span style="yes;">} </span><span style="yes;"><span style="small;">– Will select all the paragraph elements in the entire document.</span></span></p>
<h4><em></em></h4>
<h4><em><span style="small;">Class Selectors</span></em></h4>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">Select all elements which contain a particular class name. For example:</span></span></p>
<p class="MsoNormal" style="none;"><span style="yes;">.colored</span><span style="yes;"> {</span><span class="MsoHyperlink"><span style="166;"><span style="underline;"><span style="small;">declarations</span></span></span></span><span style="yes;">} – </span><span style="yes;"><span style="small;">Will select all elements which contains a class name “colored”</span></span></p>
<p class="MsoNormal" style="none;"><span style="yes;">.errorMessage</span><span style="yes;"> {</span><span class="MsoHyperlink"><span style="166;"><span style="underline;"><span style="small;">declarations</span></span></span></span><span style="yes;">}– </span><span style="yes;"><span style="small;">Will select all elements which contains a class name “errorMessage”</span></span></p>
<p class="MsoNormal" style="none;"><em></em></p>
<p class="MsoNormal" style="0in 0in 10pt;"><em><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">Notice that we need to put dot (.) before the class name.</span></span></em></p>
<h4><em></em></h4>
<h4><em><span style="small;">ID Selectors</span></em></h4>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">Select the element with a particular ID. For example:</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="yes;">#nav_main</span><span class="MsoHyperlink"><span style="166;"><span style="underline;"><span style="small;"> </span></span></span></span><span style="yes;">{</span><span class="MsoHyperlink"><span style="166;"><span style="underline;"><span style="small;">declarations</span></span></span></span><span style="yes;">} – </span><span style="yes;"><span style="small;">Will select all elements which has the ID “nav_main”</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><em><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">Notice that we need to put hash (#) before the ID.</span></span></em></p>
<p class="MsoNormal" style="0in 0in 10pt;"> </p>
<h4><span style="yes;"><em><span style="#4f81bd;"><span style="Cambria;"><span style="small;">Descentant Selectors</span></span></span></em></span></h4>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="yes;"><span style="small;">Select an element which is an descentant of another element. Descentant selectors are formed by combining multiple selectors seperated by whitespace. For example:</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="yes;">#nav_main</span><span style="yes;"> <span style="#a31515;">li</span>{</span><span class="MsoHyperlink"><span style="166;"><span style="underline;"><span style="small;">declarations</span></span></span></span><span style="yes;">} – </span><span style="yes;"><span style="small;">Will select all “li’ (list) elements which are descentant of an<span style="yes;"> </span>element with the ID<span style="yes;"> </span>“nav_main”</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="yes;"><span style="small;">Below is another example which is slightly more complex:</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="yes;">#nav_main</span><span style="yes;"> <span style="#a31515;">li</span> <span style="#a31515;">.help</span> <span style="#a31515;">#phone</span> <span style="#a31515;">#mobile</span>{</span><span class="MsoHyperlink"><span style="166;"><span style="underline;"><span style="small;">declarations</span></span></span></span><span style="yes;">}</span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">“Selects <strong>any element</strong> with an id attribute that equals mobile <em>that is a descendant of</em> <strong>any element</strong> with an id attribute that equals phone <em>that is a descendant of</em> <strong>any element</strong> with a class attribute that contains the word help <em>that is a descendant of</em> <strong>a li element</strong> <em>that is a descendant of</em> <strong>any element</strong> with an id attribute that equals nav_main”</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="small;"><strong><em><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;">Note</span></em></strong><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;">: A very interesting tool that you can use to understand more how descendant selectors work is </span></span><a href="http://tux.theopalgroup.com/cgi-bin/css3explainer/selectoracle.py"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">Select<strong>o</strong>racle</span></span></a><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">. I would strongly recommend spending some time with this tool if you are new to CSS world.</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"> </p>
<h4><em><span style="small;">Pseudo classes </span></em></h4>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">These are used to communicate state. Very common example is the various states of an anchor tag (&lt;a&gt;) like “link”, ”visited”, “hover” and “active”. These are primarily used to add special effects to some selectors. For example:</span></span></p>
<p class="MsoNormal" style="none;"><span style="yes;">a:link</span><span style="yes;"> {</span><span class="MsoHyperlink"><span style="166;"><span style="underline;"><span style="small;">declarations</span></span></span></span><span style="yes;">}<span style="yes;"> </span><span style="green;">/* unvisited link */</span></span></p>
<p class="MsoNormal" style="none;"><span style="yes;">a:visited</span><span style="yes;"> {</span><span class="MsoHyperlink"><span style="166;"><span style="underline;"><span style="small;">declarations</span></span></span></span><span style="yes;">}<span style="yes;"> </span><span style="green;">/* visited link */</span></span></p>
<p class="MsoNormal" style="none;"><span style="yes;">a:hover</span><span style="yes;"> {</span><span class="MsoHyperlink"><span style="166;"><span style="underline;"><span style="small;">declarations</span></span></span></span><span style="yes;">}<span style="yes;"> </span><span style="green;">/* mouse over link */</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="yes;">a:active</span><span style="yes;"> {</span><span class="MsoHyperlink"><span style="166;"><span style="underline;"><span style="small;">declarations</span></span></span></span><span style="yes;">}<span style="yes;"> </span><span style="green;">/* selected link */</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><em><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">Notice that we need to put colon (:) after the selector while using a pseudo class.</span></span></em></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">You need to be very careful when using pseudo classes as it can bring in some cross browser compatibility issues. There is a nice matrix available illustrating various pseudo classes and its compatibilities “</span></span><a href="http://kimblim.dk/css-tests/selectors/"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">CSS selectors and pseudo selectors browser compatibility</span></span></a><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">”.</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">You can read more about CSS selectors </span></span><a href="http://www.w3.org/TR/CSS2/selector.html"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">here</span></span></a><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">.</span></span></p>
<h3><span style="small;">CSS Declaration</span></h3>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">Declaration includes various properties and its values. So once the selector is used to identify the element, the properties of the element included in the declaration will be set to the value as per the declaration. For example:</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="yes;">background-color</span><span style="yes;">:<span style="blue;">Red</span>; <span style="green;">/* Set background color to red */</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="yes;">border</span><span style="yes;">:<span style="blue;">1px</span>; <span style="green;">/* Set border width to 1px */</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">One thing worth mentioning is the granularity of properties. For example “font” properties can be used to set all the below properties:</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><strong><span style="Calibri;"><span style="small;">font</span></span></strong></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><strong><span style="166;"><span style="Calibri;"><span style="small;">font-style</span></span></span></strong></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><strong><span style="166;"><span style="Calibri;"><span style="small;">font-variant</span></span></span></strong></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><strong><span style="166;"><span style="Calibri;"><span style="small;">font-weight</span></span></span></strong></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><strong><span style="166;"><span style="Calibri;"><span style="small;">font-size/line-height</span></span></span></strong></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><strong><span style="166;"><span style="Calibri;"><span style="small;">font-family</span></span></span></strong></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><strong><span style="166;"><span style="Calibri;"><span style="small;">caption</span></span></span></strong></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><strong><span style="166;"><span style="Calibri;"><span style="small;">icon</span></span></span></strong></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><strong><span style="166;"><span style="Calibri;"><span style="small;">menu</span></span></span></strong></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><strong><span style="166;"><span style="Calibri;"><span style="small;">message-box</span></span></span></strong></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><strong><span style="166;"><span style="Calibri;"><span style="small;">small-caption</span></span></span></strong></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><strong><span style="166;"><span style="Calibri;"><span style="small;">status-bar</span></span></span></strong></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><strong><span style="166;"><span style="Calibri;"><span style="small;">inherit</span></span></span></strong></p>
<p class="MsoNormal" style="0in 0in 10pt;"> </p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">While dealing with properties granularity one thing that can come handy is to know the shorthand to set values of these granular properties. For example:</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="yes;">font</span><span style="yes;">:<span style="blue;">italics</span> <span style="blue;">15px</span> <span style="blue;">arial</span>; <span style="green;">/*Set font style to italics, font width to 15px and font<span style="yes;"> </span>family to arial*/</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">is same as</span></span></p>
<p class="MsoNormal" style="none;"><span style="yes;">font-style</span><span style="yes;">:<span style="blue;">italic</span>;</span></p>
<p class="MsoNormal" style="none;"><span style="yes;">font-size</span><span style="yes;">:<span style="blue;">15px</span>;</span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="yes;">font-family</span><span style="yes;">:<span style="blue;">Arial</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">Border is another property which you might come across with lot of granularity. While using shorthand it is important to know the order in which these properties are assigned.</span></span></p>
<h2><span style="medium;">Understanding the “Cascade” in CSS</span></h2>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="small;">As discussed earlier browser uses selector pattern matching to identify the element to which style need to be applied. What happens when more than one declaration having the same property but with different value gets applied to the same element?</span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="small;">Browser uses the following criteria to determine the declaration that will get applied:</span></p>
<p class="MsoListParagraphCxSpFirst" style="l2 level1 lfo4;"><span style="minor-latin;"><span style="Ignore;"><span style="small;">1.</span><span style="7pt &quot;Times New Roman&quot;;"> </span></span></span><span style="small;">Importance (using !Important keyword)</span></p>
<p class="MsoListParagraphCxSpMiddle" style="l2 level1 lfo4;"><span style="minor-latin;"><span style="Ignore;"><span style="small;">2.</span><span style="7pt &quot;Times New Roman&quot;;"> </span></span></span><span style="small;">Origin (3 different origins: author, user and user agent)</span></p>
<p class="MsoListParagraphCxSpLast" style="l2 level1 lfo4;"><span style="minor-latin;"><span style="Ignore;"><span style="small;">3.</span><span style="7pt &quot;Times New Roman&quot;;"> </span></span></span><span style="small;">Specificity</span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">I will be only covering the <em>Specificity</em> in this blog. You can read more about cascading rules </span></span><a href="http://www.w3.org/TR/CSS2/cascade.html"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">here</span></span></a><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">.</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">Let us use an example to understand the “Specificity” effect.</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">Consider the following section of the DOM below:</span></span></p>
<p class="MsoNormal" style="none;"><span style="yes;">&lt;</span><span style="yes;">div</span><span style="yes;"> <span style="red;">id</span><span style="blue;">=&#8221;first&#8221;&gt;</span></span></p>
<p class="MsoNormal" style="none;"><span style="yes;"><span style="blue;">&lt;</span><span style="#a31515;">div</span> <span style="red;">id</span><span style="blue;">=&#8221;second&#8221;&gt;</span></span></p>
<p class="MsoNormal" style="none;"><span style="yes;"><span style="blue;">&lt;</span><span style="#a31515;">h1</span><span style="blue;">&gt;</span>Hello Reader<span style="blue;">&lt;/</span><span style="#a31515;">h1</span><span style="blue;">&gt;</span></span></p>
<p class="MsoNormal" style="none;"><span style="yes;"><span style="blue;">&lt;/</span><span style="#a31515;">div</span><span style="blue;">&gt;</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="yes;">&lt;/</span><span style="yes;">div</span><span style="yes;">&gt;</span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">Now let us say you have the following CSS:</span></span></p>
<p class="MsoNormal" style="none;"><span style="yes;">#first</span><span style="yes;"> <span style="#a31515;">h1</span> {<span style="red;">color</span>:<span style="blue;">Green</span>}</span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="yes;">#first</span><span style="yes;"> <span style="#a31515;">h1</span> {<span style="red;">color</span>:<span style="blue;">Black</span>}</span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">What will be the color of h1?</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">Answer is black. </span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">So in short, the last declaration wins, easy? Not very true let me give you a second scenario.</span></span></p>
<p class="MsoNormal" style="none;"><span style="yes;">#first #second</span><span style="yes;"> <span style="#a31515;">h1</span> {<span style="red;">color</span>:<span style="blue;">Green</span>}</span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="yes;">#first</span><span style="yes;"> <span style="#a31515;">h1</span> {<span style="red;">color</span>:<span style="blue;">Black</span>}</span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">What will be the color of h1 this time?</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">Answer is <span style="#00b050;">green</span>.</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">So what is said before “last declaration wins” is not completely correct. So the correct rule is “<strong><em>the last and most specific declaration wins</em></strong>”.</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">What is meant by specific or how to calculate specificity?</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">Specificity is calculated based on the following point system:</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">ID selector = 100 points</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">Class selector = 10 points</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">Element selector = 1 point</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">Now let us apply this point system in our above example.</span></span></p>
<p class="MsoNormal" style="none;"><span style="yes;">#first #second</span><span style="yes;"> <span style="#a31515;">h1</span> {<span style="red;">color</span>:<span style="blue;">Green</span>} = 100+100+1=201</span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="yes;">#first</span><span style="yes;"> <span style="#a31515;">h1</span> {<span style="red;">color</span>:<span style="blue;">Black</span>} = 100 + 1 = 101</span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">So now you know the declaration setting the <span style="#00b050;">green</span> won over declaration setting the color black even when it appeared second in the order.</span></span></p>
<h2><span style="medium;">Understanding CSS Inheritance</span></h2>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">Let us use the above DOM section and try to understand the inheritance.</span></span></p>
<p class="MsoNormal" style="none;"><span style="yes;">&lt;</span><span style="yes;">style</span><span style="yes;">&gt;</span></p>
<p class="MsoNormal" style="none;"><span style="yes;"><span style="#a31515;">#Div1</span> <span style="#a31515;">#Div2</span> { <span style="red;">color</span>:<span style="blue;">Red</span>}</span></p>
<p class="MsoNormal" style="none;"><span style="yes;">&lt;/</span><span style="yes;">style</span><span style="yes;">&gt;</span></p>
<p class="MsoNormal" style="none;"> </p>
<p class="MsoNormal" style="none;"><span style="yes;">&lt;</span><span style="yes;">div</span><span style="yes;"> <span style="red;">id</span><span style="blue;">=&#8221;first&#8221;&gt;</span></span></p>
<p class="MsoNormal" style="none;"><span style="yes;"><span style="blue;">&lt;</span><span style="#a31515;">div</span> <span style="red;">id</span><span style="blue;">=&#8221;second&#8221;&gt;</span></span></p>
<p class="MsoNormal" style="none;"><span style="yes;"><span style="blue;">&lt;</span><span style="#a31515;">h1</span><span style="blue;">&gt;</span>Hello Reader<span style="blue;">&lt;/</span><span style="#a31515;">h1</span><span style="blue;">&gt;</span></span></p>
<p class="MsoNormal" style="none;"><span style="yes;"><span style="blue;">&lt;/</span><span style="#a31515;">div</span><span style="blue;">&gt;</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="yes;">&lt;/</span><span style="yes;">div</span><span style="yes;">&gt;</span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">See how it renders on the browser below:</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;"><a href="http://blogs.globallogic.com/wp-content/uploads/2011/05/hello.jpg"><img class="alignnone size-medium wp-image-1147" src="http://blogs.globallogic.com/wp-content/uploads/2011/05/hello.jpg" alt="" width="99" height="17" /></a></span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"> </p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">So even though the style was only applied to the container &lt;div&gt; element the &lt;h1&gt; element inherited the color.</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">Most of the properties are inheritable not all though. Simplest way to memorize which properties can and cannot inherit is by memorizing the following principle:</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">“<strong><em>Text related properties gets inherited, layout related properties don’t</em></strong>”</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">The table below includes most commonly used text and layout related properties:</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"> </p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;"><a href="http://blogs.globallogic.com/wp-content/uploads/2011/05/inheritance.jpg"><img class="alignnone size-medium wp-image-1140" src="http://blogs.globallogic.com/wp-content/uploads/2011/05/inheritance-300x256.jpg" alt="" width="300" height="256" /></a></span></span></p>
<h2><span style="medium;">The “Box Model”</span></h2>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">Before we wind up I would like to briefly touch the “Box Model” which is basic but a very important concept in CSS. I will use the image below to depict the Box Model:</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"> </p>
<p class="MsoNormal" style="0in 0in 10pt;"><a href="http://blogs.globallogic.com/wp-content/uploads/2011/05/boxmodel.jpg"><img class="alignnone size-medium wp-image-1141" src="http://blogs.globallogic.com/wp-content/uploads/2011/05/boxmodel-300x178.jpg" alt="" width="300" height="178" /></a></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">So now that you have an understanding what and where padding, border etc fit in the box model let us try to set some values.</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">For example:</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">Border: 1px; - Set border width (top, right, bottom and left) to 1px</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">Border: 1px 2 px – Set top and bottom border width to 1px and left and right to 2px</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">Border: 1px 2px 3px 4px – Set border width top to 1px, right to 2px, bottom to 3px and left to 4px<em></em></span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="small;"><em><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;">Notice that values are set in the clockwise order</span></em><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;">.</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">You can read more on Box Model </span></span><a href="http://www.w3schools.com/css/css_boxmodel.asp"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">here</span></span></a><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;">.</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt;"> </p>
<div></div>
<div><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"></span></div>
<p><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;"></p>
<p class="MsoNormal" style="0in 0in 10pt;"><span style="&quot;Microsoft Sans Serif&quot;,&quot;sans-serif&quot;;"><span style="small;"><em>Hope this blog helped to you to have some basic understanding of various concepts of CSS. I would like to thank my colleague </em></span><a href="http://in.linkedin.com/pub/joydeep-das/8/344/79a"><span style="small;"><em>Joydeep Das</em></span></a><span style="small;"><em> who is a design consultant for his valuable inputs to various sections of this blog.</em></span></span></p>
<p> </p>
<p> </p>
<p></span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.globallogic.com/cascading-style-sheet-css-%e2%80%93-what-must-web-developer-know/feed</wfw:commentRss>
		</item>
		<item>
		<title>Optimizing ASP.NET web application - Part 3a (ASP.NET Level Optimization Techniques)</title>
		<link>http://blogs.globallogic.com/optimizing-aspnet-web-application-part-3a-aspnet-level-optimization-techniques</link>
		<comments>http://blogs.globallogic.com/optimizing-aspnet-web-application-part-3a-aspnet-level-optimization-techniques#comments</comments>
		<pubDate>Thu, 05 May 2011 07:09:32 +0000</pubDate>
		<dc:creator>dhejov</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<category><![CDATA[Web 2.0]]></category>

		<category><![CDATA[AcquireRequestState]]></category>

		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[asp.net compilation]]></category>

		<category><![CDATA[asp.net optimization]]></category>

		<category><![CDATA[ASP.NET ViewState Helper]]></category>

		<category><![CDATA[ControlState]]></category>

		<category><![CDATA[EnableSessionState]]></category>

		<category><![CDATA[EnableViewState]]></category>

		<category><![CDATA[Google Closure Minifier]]></category>

		<category><![CDATA[Microsoft Ajax Minifier]]></category>

		<category><![CDATA[MS AJAX minifier Task]]></category>

		<category><![CDATA[obfuscation]]></category>

		<category><![CDATA[Optimizing CSS and Script files]]></category>

		<category><![CDATA[Optimizing Images]]></category>

		<category><![CDATA[Optimizing Session State]]></category>

		<category><![CDATA[Optimizing ViewState]]></category>

		<category><![CDATA[Packer.NET]]></category>

		<category><![CDATA[ReleaseRequestState]]></category>

		<category><![CDATA[RIOT]]></category>

		<category><![CDATA[Session Partitioning]]></category>

		<category><![CDATA[Session State]]></category>

		<category><![CDATA[SessionIDManager]]></category>

		<category><![CDATA[SessionStateModule]]></category>

		<category><![CDATA[Sprite and Image Optimization Framework]]></category>

		<category><![CDATA[ViewState]]></category>

		<category><![CDATA[YUI Build Task]]></category>

		<category><![CDATA[YUI Compressor]]></category>

		<guid isPermaLink="false">http://blogs.globallogic.com/?p=1128</guid>
		<description><![CDATA[This is third blog in a series of blogs which would be focusing on optimizing the performance of an ASP.NET web application. Below are links to previous blogs:
1.       Optimizing ASP.NET web application - Part 1 (Let the journey begin)
2.       Optimizing ASP.NET web application - Part 2 (Measuring Performance)
In this blog we will be focusing on [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal" style="0in 0in 10pt"><span style="small;"><span style="Calibri;">This is third blog in a series of blogs </span><span style="'Times New Roman','serif';">which would be focusing on optimizing the performance of an ASP.NET web application. Below are links to previous blogs:</span></span></p>
<p class="MsoListParagraphCxSpFirst" style="l5 level1 lfo1"><span style="minor-latin"><span style="Ignore"><span style="small;">1.</span><span style="'Times New Roman';">       </span></span></span><a href="http://blogs.globallogic.com/optimizing-aspnet-web-application-part-1-let-the-journey-begin"><span style="small;">Optimizing ASP.NET web application - Part 1 (Let the journey begin)</span></a></p>
<p class="MsoListParagraphCxSpLast" style="l5 level1 lfo1"><span style="minor-latin"><span style="Ignore"><span style="small;">2.</span><span style="'Times New Roman';">       </span></span></span><a href="http://blogs.globallogic.com/optimizing-aspnet-web-application-part-2-measuring-performance"><span style="small;">Optimizing ASP.NET web application - Part 2 (Measuring Performance)</span></a></p>
<p class="MsoNormal" style="0in 0in 10pt"><span style="small;">In this blog we will be focusing on optimization techniques which can be applied at ASP.NET level. For example I will not be covering Static/Dynamic compression as it will be covered in a later blog in this series “IIS Level Optimization techniques”.</span></p>
<p class="MsoNormal" style="0in 0in 10pt"><strong><span style="underline;"><span style="14pt;">Set debug=”false”</span></span></strong></p>
<p class="MsoNormal" style="0in 0in 10pt"><span style="small;">Yes this is trivial but if missed can have a great performance implication. Make sure your web.config never has this entry:</span></p>
<p class="MsoNormal" style="0in 0in 10pt"><span style="10pt;">&lt;compilation debug=”true”/&gt;</span></p>
<p class="MsoNormal" style="0in 0in 10pt"><span style="small;">You can even delete the complete entry as the default value for “debug” is “false”.<span style="yes">  </span>This is completely different from the debug/release build mode in Visual Studio rather has only to do with how asp.net pages are compiled and served. You can read more about the why you should never have debug=”true” in ScottGu’s blog “</span><a href="http://weblogs.asp.net/scottgu/archive/2006/04/11/442448.aspx"><span style="small;">Don’t run production ASP.NET Applications with debug=”true” enabled</span></a><span style="small;">”</span></p>
<p class="MsoNormal" style="0in 0in 10pt"><strong><span style="underline;"><span style="14pt;">Optimizing ViewState </span></span></strong></p>
<p class="MsoNormal" style="0in 0in 10pt"><span style="small;">First of all if you don’t need ViewState support on a particular page, explicitly disable the same in the Page directive:</span></p>
<p class="MsoNormal" style="0in 0in 10pt"><span style="small;">“EnableViewState=false”</span></p>
<p class="MsoNormal" style="0in 0in 10pt"><span style="small;">Disabling ViewState at page level alone would not solve your problem entirely you will have set it at different control level to ensure ViewState of the page is completely empty.<span style="yes">  </span>This is because of the </span><a href="http://www.pluralsight-training.net/community/blogs/fritz/archive/2004/07/01/472.aspx"><span style="small;">ControlState</span></a><span style="small;"> introduced in ASP.NET 2.0 which is independent from ViewState yet stored in the same hidden variable. </span></p>
<p class="MsoNormal" style="0in 0in 10pt"><span style="small;">Note: To measure ViewState you can use Fiddler extension </span><a href="http://www.binaryfortress.com/ASPNET-ViewState-Helper-Fiddler/"><span style="small;">ASP.NET ViewState Helper</span></a><span style="small;">.</span></p>
<p class="MsoNormal" style="0in 0in 10pt"><span style="small;">Most of the time disabling ViewState will not be an option in such case I would recommend to use ViewState compression techniques. My colleague Manoj Garg has a very detailed </span><a href="http://gargmanoj.wordpress.com/2009/09/16/viewstate-compression-in-asp-net-2-0/"><span style="small;">blog</span></a><span style="small;"> entry on how to compress ViewState and also explain about the relationship between ViewState and ControlState.</span></p>
<p class="MsoNormal" style="0in 0in 10pt"><span style="small;">I have also come across some techniques in which ViewState is stored in the server (Session) there by completely eliminating the ViewState bytes from the page size. Scott Hanselman has a </span><a href="http://www.hanselman.com/blog/MovingViewStateToTheSessionObjectAndMoreWrongheadedness.aspx"><span style="small;">blog</span></a><span style="small;"> entry explaining how to do the same.</span><span style="small;"> </span></p>
<p class="MsoNormal" style="0in 0in 10pt"><strong><span style="underline;"><span style="14pt;">Optimizing Session State</span></span></strong></p>
<p class="MsoNoSpacing" style="0in 0in 0pt"><span style="small;">I would recommend everyone of you to read this interesting MSDN article on ASP.NET session state management “</span><a href="http://msdn.microsoft.com/en-us/magazine/cc163730.aspx"><span style="small;">Fast, Scalable, and Secure Session State Management for Your Web Applications</span></a><span style="small;">”.</span><span style="small;"> </span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt"><span style="small;">Let me briefly explain how the session works. Session state feature is implemented by the “</span><a href="http://msdn.microsoft.com/en-us/library/system.web.sessionstate.sessionstatemodule.aspx"><span style="small;">SessionStateModule</span></a><span style="small;">” which is a httpmodule that is plugged into the asp.net request processing pipeline.<span style="yes">  </span>This module hooks into to request state related events “</span><a href="http://msdn.microsoft.com/en-us/library/system.web.httpapplication.acquirerequeststate.aspx"><span style="small;">AcquireRequestState</span></a><span style="small;">” and “</span><a href="http://msdn.microsoft.com/en-us/library/system.web.httpapplication.releaserequeststate.aspx"><span style="small;">ReleaseRequestState</span></a><span style="small;">”. During the AcquireRequestState the Session ID is retrieved from the request and used to fetch the session information from the session store. During the ReleaseRequestState, either a new session ID (initial request which require session) is created to store the session details or if the session ID already exist session store will be updated with the changes.</span><span style="small;"> </span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt"><span style="small;">Optimization strategy will depend on whether you are using in-proc or out-proc session management.<span style="yes">  </span>There are some common optimization principles that are applicable to both in-proc and out-proc scenario:</span></p>
<p class="MsoNoSpacing" style="l2 level1 lfo6"><span style="minor-latin"><span style="Ignore"><span style="small;">1.</span><span style="'Times New Roman';">       </span></span></span><span style="small;">Disable Session State on pages which don’t need session</span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt 0.5in"><span style="small;">This will mean that session state will not be loaded from the store at the beginning of the request or stored into the store at the end of response.</span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt"><span style="small;">This can be either done at the page level or application level.</span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt 0.5in"><span style="small;">Page Level:</span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt 0.5in"><span style="small;">&lt;%@ Page EnableSessionState=&#8221;False&#8221; %&gt;</span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt 0.5in"><span style="small;">Application level:</span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt 0.5in"><span style="small;">&lt;configuration&gt;</span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt"><span style="small;"><span style="Calibri;"><span style="yes">    </span><span style="2">                            </span>&lt;system.web&gt;</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt"><span style="small;"><span style="Calibri;"><span style="yes">        </span><span style="3">                                        </span>&lt;pages enableSessionState=&#8221;false&#8221; /&gt;</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt"><span style="small;"><span style="Calibri;"><span style="yes">    </span><span style="2">                            </span>&lt;/system.web&gt;</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt"><span style="small;">&lt;/configuration&gt;</span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt"><span style="small;"> </span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt"><span style="small;"><span style="Calibri;"><strong>Note:</strong> Even when session is disabled at the page level there will be still some call to session store to mark session as accessed to prevent session from getting expired. </span></span></p>
<p class="MsoNoSpacing" style="l2 level1 lfo6"><span style="minor-latin"><span style="Ignore"><span style="small;">2.</span><span style="'Times New Roman';">       </span></span></span><span style="small;">Set Read-Only Session Access</span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt 0.5in"><span style="small;">There are many scenarios in which we cannot disable session for a page but then we might be able to mark session access as read-only as the page is only reading from session. When set to read-only loading of session and marking session as accessed will only be done and will not involve any update or insert activity.</span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt 0.5in"><span style="small;">This can be either done at the page level or application level.</span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt 0.5in"><span style="small;">Page Level:</span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt 0.5in"><span style="small;">&lt;%@ Page EnableSessionState=&#8221;ReadOnly&#8221; %&gt;</span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt 0.5in"><span style="small;">Application Level:</span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt 0.5in"><span style="small;">&lt;configuration&gt;</span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt 0.5in"><span style="small;"><span style="Calibri;"><span style="yes">    </span>&lt;system.web&gt;</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt 0.5in"><span style="small;"><span style="Calibri;"><span style="yes">        </span>&lt;pages enableSessionState=&#8221;ReadOnly&#8221; /&gt;</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt 0.5in"><span style="small;"><span style="Calibri;"><span style="yes">    </span>&lt;/system.web&gt;</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt 0.5in"><span style="small;">&lt;/configuration&gt;</span></p>
<p class="MsoNoSpacing" style="l2 level1 lfo6"><span style="minor-latin"><span style="Ignore"><span style="small;">3.</span><span style="'Times New Roman';">       </span></span></span><span style="small;">Reduce amount of session data</span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt 0.5in"><span style="small;">Size of data stored in session will have serious implication on the performance of each request as the session data need to be loaded for each request. Magnitude of the performance impact increases multifold in case of out-proc session management. Now the question is how you will measure the session state. Till date I have not found any easy mechanism to retrieve this information and what I fall back on is the technique of changing the session store to SQL Server and measure the size over there. (If any of you are aware about a better or at least easier solution please post it as a comment)</span></p>
<p class="MsoListParagraphCxSpFirst" style="l2 level1 lfo6"><span style="minor-latin"><span style="Ignore"><span style="small;">4.</span><span style="'Times New Roman';">       </span></span></span><span style="small;">Manage what is in your session</span></p>
<p class="MsoListParagraphCxSpLast" style="0in 0in 10pt 0.5in"><span style="small;">Apart from the size it also matter what is stored in the session as the type of the content will determine the serialization cost incurred especially when you are using out-proc session management. Primarily session state use custom serialization mechanism to convert the session data into binary blob which has direct support for .NET Framework primitive types. So I would recommend avoiding storing objects in session and rather stick to using primitive data types whenever possible. </span></p>
<p class="MsoNormal" style="0in 0in 10pt"><span style="small;">If you are using out-proc session I would recommend having a custom implementation of SessionIDManager class so that you can optimize both fetching of session ID and also marking session accessed so that it best suits your requirement.</span></p>
<p class="MsoNormal" style="0in 0in 10pt"><span style="small;">One other feature that you can look at while using out-proc session is the concept of Session Partitioning. I won’t be covering the details of how to implement session partitioning but if you are interested in knowing more about the same there is a very nice </span><a href="http://blog.maartenballiauw.be/post/2008/01/ASPNET-Session-State-Partitioning.aspx"><span style="small;">blog</span></a><span style="small;"> by </span><a href="http://blog.maartenballiauw.be/page/About-me.aspx"><span style="small;">Maarten Balliauw</span></a><span style="small;"> covering session partition in detail. In short State partitioning enables the session data and the associated processing load to be divided between multiple out-of-process state stores, allowing the session state load to scale as the Web farm grows and the number of concurrent session increases.</span><span style="small;"> </span></p>
<p class="MsoNormal" style="0in 0in 10pt"><strong><span style="underline;"><span style="14pt;">Optimizing Images</span></span></strong></p>
<p class="MsoNormal" style="0in 0in 10pt"><span style="small;">Yes this is trivial again but I must say based on my experience at 7 out of 10 web application miss to ensure that all the images used are optimized. Image optimization involve two aspects</span></p>
<p class="MsoListParagraphCxSpFirst" style="l1 level1 lfo2"><span style="minor-latin"><span style="Ignore"><span style="small;">1.</span><span style="'Times New Roman';">       </span></span></span><span style="small;">Reduction of image size</span></p>
<p class="MsoListParagraphCxSpLast" style="l1 level1 lfo2"><span style="minor-latin"><span style="Ignore"><span style="small;">2.</span><span style="'Times New Roman';">       </span></span></span><span style="small;">Reduction of image count (in turn reduce request count)</span></p>
<p class="MsoNormal" style="0in 0in 10pt"><span style="small;">Regarding reducing the image size, If you are fortunate to have a graphic designer in your team use his/her expertise and if your unfortunate you can use tool like </span><a href="http://luci.criosweb.ro/riot/"><span style="small;">RIOT</span></a><span style="small;"> or similar tool.</span></p>
<p class="MsoNormal" style="0in 0in 10pt"><span style="small;">Regarding reducing the image count you can try to apply CSS sprites which will help you to combine multiple images into one. I will not go into details of what CSS sprites are and how it is done but you can read more about CSS Sprites in </span><a href="http://www.websiteoptimization.com/speed/tweak/css-sprites/"><span style="small;">here</span></a><span style="small;">. But rather I would like to mention an interesting framework I came across recently which can help you use sprites is a much friendlier manner, </span><a href="http://aspnet.codeplex.com/releases/view/50140"><span style="small;">Sprite and Image Optimization Framework</span></a><span style="small;">. It is still in preview and here is a quick </span><a href="http://www.youtube.com/watch?v=URuuSlLZcX0"><span style="small;">video</span></a><span style="small;"> on how to use this framework.</span><span style="small;"> </span></p>
<p class="MsoNormal" style="0in 0in 10pt"><strong><span style="underline;"><span style="14pt;">Optimizing CSS and Script files</span></span></strong></p>
<p class="MsoNormal" style="0in 0in 10pt"><span style="small;">Again by optimization I mean:</span></p>
<p class="MsoListParagraphCxSpFirst" style="l4 level1 lfo3"><span style="minor-latin"><span style="Ignore"><span style="small;">1.</span><span style="'Times New Roman';">       </span></span></span><span style="small;">Reduction of file size</span></p>
<p class="MsoListParagraphCxSpLast" style="l4 level1 lfo3"><span style="minor-latin"><span style="Ignore"><span style="small;">2.</span><span style="'Times New Roman';">       </span></span></span><span style="small;">Reduction of file count (in turn reduce request count)</span></p>
<p class="MsoNormal" style="0in 0in 10pt"><span style="small;">One of the techniques used to reduce the size of file is called Minification. Few of the leading minifier frameworks which you can use are:</span></p>
<p class="MsoListParagraphCxSpFirst" style="l3 level1 lfo4"><span style="minor-latin"><span style="Ignore"><span style="small;">1.</span><span style="'Times New Roman';">       </span></span></span><a href="http://developer.yahoo.com/yui/compressor/"><span style="small;">YUI Compressor</span></a></p>
<p class="MsoListParagraphCxSpMiddle" style="l3 level1 lfo4"><span style="minor-latin"><span style="Ignore"><span style="small;">2.</span><span style="'Times New Roman';">       </span></span></span><a href="http://code.google.com/closure/compiler/docs/gettingstarted_app.html"><span style="small;">Google Closure Minifier/Complier</span></a></p>
<p class="MsoListParagraphCxSpMiddle" style="l3 level1 lfo4"><span style="minor-latin"><span style="Ignore"><span style="small;">3.</span><span style="'Times New Roman';">       </span></span></span><a href="http://aspnet.codeplex.com/releases/view/40584"><span style="small;">Microsoft Ajax Minifier</span></a></p>
<p class="MsoListParagraphCxSpLast" style="l3 level1 lfo4"><span style="minor-latin"><span style="Ignore"><span style="small;">4.</span><span style="'Times New Roman';">       </span></span></span><a href="http://svn.offwhite.net/trac/SmallSharpTools.Packer/"><span style="small;">Packer.NET</span></a></p>
<p class="MsoNormal" style="0in 0in 10pt"><span style="small;"><span style="Calibri;">(There are many more but these are only ones I am familiar with </span><span style="Wingdings;"><span style="Wingdings">L</span></span><span style="Calibri;"> ). Most the above framework also provides you a feature which can further reduce the size called </span></span><a href="http://en.wikipedia.org/wiki/Obfuscation"><em><span style="bold"><span style="small;">obfuscation</span></span></em></a><span style="bold"><span style="small;"><span style="Calibri;">. Word of caution use this feature very prudently especially on your custom script files as these is a more intrusive process which involve optimizing your variable and function names etc. </span></span></span></p>
<p class="MsoNormal" style="0in 0in 10pt"><span style="bold"><span style="small;">You should try to make minification as the part of your build process. MSBuild guru Sayed Ibrahim Hashimi has a </span></span><a href="http://sedodream.com/CategoryView,category,Deployment.aspx"><span style="bold"><span style="small;">blog</span></span></a><span style="bold"><span style="small;"> entry how to add minification as part of your build process using Packer.NET. There are also build task like </span></span><a href="http://www.asp.net/ajaxlibrary/AjaxMinTask.ashx"><span style="bold"><span style="small;">MS AJAX minifier Task</span></span></a><span style="bold"><span style="small;">, </span></span><a href="http://yuicompressor.codeplex.com/"><span style="bold"><span style="small;">YUI Build Task</span></span></a><span style="small;"><span style="Calibri;"><span style="bold"> </span>etc which you can use in your build script to achieve the same.</span></span></p>
<p class="MsoNormal" style="0in 0in 10pt"><span style="small;">Second technique that you can to reduce the file size is compression. On approach I have seen being used to achieve compression is by using custom handler (ashx). Custom handler will serve the compressed CSS and JS files. Although I have used this approach in the past I have been never a big fan of this approach as compression can be better achieved by using IIS compression. But custom handlers approach can be useful when your web application is hosted on a Shared </span></p>
<p class="MsoNormal" style="0in 0in 10pt"><a href="http://www.codeproject.com/Members/Omar-Al-Zabir"><span style="small;">Omar Al Zabir</span></a><span style="small;"> wrote an interesting </span><a href="http://www.codeproject.com/KB/aspnet/HttpCombine.aspx"><span style="small;">article</span></a><span style="small;"> in which he explains how we can use the custom handler approach not just to compress the files but also combine the files. </span></p>
<p class="MsoNormal" style="0in 0in 10pt"><span style="small;">Combining CSS and JS file will help us reduce the request counts which in turn will make your web page render fast.</span></p>
<p class="MsoNormal" style="0in 0in 10pt"><span style="small;">Before we conclude I would like to add the following rules pertaining to CSS and JS files to be followed to ensure web page performance:</span></p>
<p class="MsoListParagraphCxSpFirst" style="l0 level1 lfo5"><span style="bold"><span style="Ignore"><span style="small;">1.</span><span style="'Times New Roman';">       </span></span></span><span style="bold"><span style="small;">Put CSS at the Top (</span></span><a href="http://developer.yahoo.com/blogs/ydn/posts/2007/07/high_performanc_4/"><span style="bold"><span style="small;">Rule 5</span></span></a><span style="bold"><span style="small;"><span style="Calibri;">)</span></span></span></p>
<p class="MsoListParagraphCxSpLast" style="l0 level1 lfo5"><span style="bold"><span style="Ignore"><span style="small;">2.</span><span style="'Times New Roman';">       </span></span></span><span style="bold"><span style="small;">Move Scripts to the Bottom (</span></span><a href="http://developer.yahoo.com/blogs/ydn/posts/2007/07/high_performanc_5/"><span style="bold"><span style="small;">Rule 6</span></span></a><span style="bold"><span style="small;"><span style="Calibri;">)</span></span></span></p>
<p class="MsoNormal" style="0in 0in 10pt"><span style="small;">Having CSS included in the HEAD tag allows the page render progressively. Moving JS to bottom again enable progressive rendering but also improve download parallelism as JS request are blocking calls.</span></p>
<p class="MsoNormal" style="0in 0in 10pt"><span style="small;">Detailed explanation of these rules and how violation of these rules can adversely impact the page performance in covered in the link (associated with the rule)</span></p>
<p class="MsoNormal" style="0in 0in 10pt"><span style="small;"> </span></p>
<p class="MsoNormal" style="0in 0in 10pt"><strong><em><span style="small;"><span style="Calibri;">There are many more optimization techniques that can be applied at ASP.NET level which I would be covering as the part of this series. But to keep each blog entry to a reasonable size I will be covering them in the next blog in the series.</span></span></em></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.globallogic.com/optimizing-aspnet-web-application-part-3a-aspnet-level-optimization-techniques/feed</wfw:commentRss>
		</item>
		<item>
		<title>Optimizing ASP.NET web application - Part 2 (Measuring Performance)</title>
		<link>http://blogs.globallogic.com/optimizing-aspnet-web-application-part-2-measuring-performance</link>
		<comments>http://blogs.globallogic.com/optimizing-aspnet-web-application-part-2-measuring-performance#comments</comments>
		<pubDate>Sun, 27 Mar 2011 20:17:55 +0000</pubDate>
		<dc:creator>dhejov</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<category><![CDATA[Web 2.0]]></category>

		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[Boomerang]]></category>

		<category><![CDATA[Charles proxy]]></category>

		<category><![CDATA[DynaTrace]]></category>

		<category><![CDATA[Episode]]></category>

		<category><![CDATA[Fiddler]]></category>

		<category><![CDATA[HttpWatch]]></category>

		<category><![CDATA[Jiffy]]></category>

		<category><![CDATA[MSFast]]></category>

		<category><![CDATA[Navigation Timing]]></category>

		<category><![CDATA[PageSpeed]]></category>

		<category><![CDATA[PageTest]]></category>

		<category><![CDATA[Performance Optimization]]></category>

		<category><![CDATA[Web Timing API]]></category>

		<category><![CDATA[window.msPerformance.timing]]></category>

		<category><![CDATA[Wireshark]]></category>

		<category><![CDATA[YSlow]]></category>

		<guid isPermaLink="false">http://blogs.globallogic.com/?p=1092</guid>
		<description><![CDATA[ 
This is the second blog in a series of blogs which would be focusing on optimizing the performance of an ASP.NET web application. In the first part I tried to explain where we should start while investigating the poor performance and why measuring the performance is the key to the entire exercise of performance optimization.
 
Let [...]]]></description>
			<content:encoded><![CDATA[<p> </p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">This is the second blog in a series of blogs which would be focusing on optimizing the performance of an ASP.NET web application. In the first part I tried to explain where we should start while investigating the poor performance and why measuring the performance is the key to the entire exercise of performance optimization.</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> </span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">Let me set the context for this blog with an acronym:</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="small;"><strong><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;">YCMWYCM</span></strong><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"> – <strong><em>You Can’t Manage What You Can’t Measure</em></strong> </span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> </span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">Getting the accurate measure is not only important to assess the performance but also to assess how each of the optimization technique improved the performance of your website. </span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> </span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">Traditionally there are 2 approaches when it comes to measuring website performance</span></span></p>
<p class="MsoNoSpacing" style="l1 level1 lfo1;"><span style="'Times New Roman';"><span style="Ignore;"><span style="small;">1.</span><span style="7pt &quot;Times New Roman&quot;;">      </span></span></span><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">JavaScript instrumentation</span></span></p>
<p class="MsoNoSpacing" style="l1 level1 lfo1;"><span style="'Times New Roman';"><span style="Ignore;"><span style="small;">2.</span><span style="7pt &quot;Times New Roman&quot;;">      </span></span></span><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">Using tools which are either proxies/sniffers (Fiddler, Charles proxy etc) or browser plugins (YSlow, HttpWatch etc)</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">Although listed first I will recommend to start with using tool primarily due to the ease with which you can get performance metrics of your website. For the completion of the blog I will also cover JS instrumentation and also some recent initiative in this direction.</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> </span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><strong><span style="underline;"><span style="12pt;">Using Tools</span></span></strong></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">Today we have too many tools at our disposal when it comes to obtain relatively a very accurate measure of the performance. To name few of them:</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><a href="http://www.fiddler2.com/fiddler2/"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">Fiddler</span></span></a><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> (my favorite)</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><a href="http://www.httpwatch.com/"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">HttpWatch</span></span></a></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><a href="http://www.charlesproxy.com/"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">Charles proxy</span></span></a><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> (Not a freeware)</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><a href="http://www.wireshark.org/"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">Wireshark</span></span></a><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> (Can go beyond HTTP)</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><a href="http://www.dynatrace.com/"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">DynaTrace</span></span></a></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><a href="http://developer.yahoo.com/yslow/"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">YSlow</span></span></a><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> (From Yahoo)</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><a href="http://code.google.com/speed/page-speed/"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">PageSpeed</span></span></a><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> (From Google)</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> </span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">Technically you can categorize these tools into either http proxies/sniffers or browser plugins. Both of them have their own strengths and weakness. Tool selection should not be based on technique used rather should based on whether <span style="yes;"> </span>you want to measure is Response Time or Perceived Response Time. </span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> </span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">Dictionary definition of Response Time is:</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><em><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">The time elapsed between a stimulus and the response to it. </span></span></em></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><em><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> </span></span></em></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">So in terms of web application, response time would mean:</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><em><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">The time elapsed between the first byte sent by the browser as the part of a page request and the last byte of the page received including all objects in the page like image, JavaScript etc</span></span></em></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> </span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">Defining perceived response time is a more complex subject. For simplicity let us say it is the time when the user perceives the page to be loaded.<span style="yes;">  </span>If you want to master this concept I would recommend you to have read “</span></span><a href="http://www.amazon.com/dp/0321509188/"><strong><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">Designing and Engineering Time: The Psychology of Time Perception in Software</span></span></strong></a><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">” </span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> </span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">Response times of a website can be measured using http proxies/sniffers whereas browser plugins can do a better job when it comes to measuring the perceived response time. </span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> </span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">I would recommend to start with measuring the response time and my favorite tool is Fiddler. It is an essential tool that every developer should have some degree of mastery on.<span style="yes;">  </span>There is an introductory </span></span><a href="http://www.fiddler2.com/fiddler/help/video/FiddlerQuickStart.wmv"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">video</span></span></a><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> on the fiddler website that will get you up to speed.<span style="yes;">  </span>Reasons why I like fiddler the most are:</span></span></p>
<p class="MsoNoSpacing" style="l0 level1 lfo2;"><span style="Symbol;"><span style="Ignore;"><span style="small;">·</span><span style="7pt &quot;Times New Roman&quot;;">         </span></span></span><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">It is free </span></span></p>
<p class="MsoNoSpacing" style="l0 level1 lfo2;"><span style="Symbol;"><span style="Ignore;"><span style="small;">·</span><span style="7pt &quot;Times New Roman&quot;;">         </span></span></span><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">Extensibility: It is easy to extend the existing feature especially with my favorite language c#. Read more </span></span><a href="http://www.fiddlertool.com/fiddler/dev/IFiddlerExtension.asp"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">here</span></span></a></p>
<p class="MsoNoSpacing" style="l0 level1 lfo2;"><span style="Symbol;"><span style="Ignore;"><span style="small;">·</span><span style="7pt &quot;Times New Roman&quot;;">         </span></span></span><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">Fiddler Extension:<span style="yes;">  </span>There quite a number of very handy Fiddler extensions available at this </span></span><a href="http://www.fiddlertool.com/fiddler2/extensions.asp"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">location</span></span></a><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">.</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">A detailed dive into fiddler is not within the scope of this blog (but will be writing one pretty soon as it is long overdue).</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">Being my favorite does not make Fiddler in anyway the best choice available. Would recommend everyone to have anyone of the tool as their favorite and only switch between tool when the need arise. For example there are times when I use Wireshark when I suspect that the problem is deeper than the http layer.</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> </span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">When it comes of browser plugins some of the preferred choices are YSlow, PageSpeed but these only work with Firebug/Firefox. Considering the percentage of internet user using IE (</span></span><a href="http://www.w3schools.com/browsers/browsers_stats.asp"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">Stats</span></span></a><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">) it is important for any website to also measure the performance on IE.<span style="yes;">  </span>Most of the time I used </span></span><a href="http://sourceforge.net/projects/pagetest/"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">PageTest</span></span></a><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"><span style="yes;">  </span>or I must say was the only option. Recently I came across a one more interesting option from MySpace, </span></span><a href="http://msfast.myspace.com/"><strong><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">MSFast</span></span></strong></a><span style="small;"><strong><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;">.</span></strong></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> </span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">One additional tool I would highly recommend is DynaTrace, especially due to the fact that it is capable to capture the performance measures like JavaScript execution, Rendering Time, CPU Utilization, Asynchronous Requests and Network Requests. <span style="yes;"> </span>DynaTrace used to only support IE browser but from DynaTrace 3.0 <em>beta</em> it also supports Firefox.</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> </span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><strong><span style="underline;"><span style="12pt;">JavaScript instrumentation</span></span></strong></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><strong><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> </span></span></strong></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">I am sure most of you would have used JavaScript “<strong><em>getTime</em></strong>()” method to measure performance of some method or some critical code path. JavaScript instrumentation at the core uses the same technique.<span style="yes;">  </span>But then it was primarily during the development phase. Using this technique on a live site is fairly tricky and the most important pitfall is the impact on performance due to instrumentation code. The other big challenge is how and where to collect the data generated by your instrumentation code.</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> </span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">One interesting framework I came across that makes it very easy to instrument your JS is </span></span><a href="http://code.google.com/p/jiffy-web/"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">Jiffy</span></span></a><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">. Jiffy primarily has a library that makes instrumentation very easy and measure suite that include a proxy and DB. Now the problem is that I have not seen any update to the project for a long long time. </span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> </span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">My favorite one when it comes to JS instrumentation is </span></span><a href="https://github.com/yahoo/boomerang"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">Boomerang</span></span></a><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> from Yahoo. Of course there is </span></span><a href="http://stevesouders.com/episodes/"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">Episodes</span></span></a><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> from Steve Sounders but unfortunately never had a chance to explore this framework.</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> </span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">There were some interesting initiative by Microsoft along these lines but due to some reason never came to limelight. One which I caught my interest was </span></span><a href="http://research.microsoft.com/en-us/downloads/e82e1a27-e500-4e91-85fd-75886242acfc/default.aspx"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">Ajax View JavaScript Instrumentation Proxy</span></span></a><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">, which saved my time of writing the instrumentation code. I am not sure but I guess Microsoft used this same proxy in </span></span><a href="http://archive.msdn.microsoft.com/AjaxView"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">Microsoft Visual Studio AJAX Profiling Extensions</span></span></a><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">, but I never used this extension so cannot comment on its effectiveness.</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> </span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">Now as I mentioned early most of these instrumentation framework uses “<strong><em>getTime</em></strong>()” method either having it at the beginning of document or writing into cookie during <strong><em>onbeforeunload</em></strong> event of the previous page. </span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">But then one fine day I read a very interesting </span></span><a href="http://ejohn.org/blog/accuracy-of-javascript-time/"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">blog</span></span></a><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> by none other than the JavaScript guru, John Resign about the accuracy of the “<strong><em>getTime</em></strong>()”.<span style="yes;">  </span>In simple language there is going to be some percentage of error when you use JavaScript “<strong><em>getTime</em></strong>()”.<span style="yes;">  </span>This put a very big question mark on the output of most of the frameworks.</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">Finally there is something from W3C, a </span></span><a href="http://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">Web Timing API</span></span></a><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> specification for browser which can be used by the developers to accurately measure website performance using JavaScript. For change IE was the first one to ride on this new wave. A prototype implementation of the Web Timings </span></span><a href="http://dev.w3.org/2006/webapi/WebTiming/#navigation-timing"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">NavigationTiming</span></span></a><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> interface called <strong><em>window.msPerformance.timing</em></strong> is available with IE9. Now it is possible to retrieve performance information from this interface as soon as the DOM finishes loading.</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> </span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">Both Chrome and Firefox will be soon providing a similar implementation. Read more about update from Chrome team </span></span><a href="http://blog.chromium.org/2010/07/do-you-know-how-slow-your-web-page-is.html"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">here</span></span></a><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> and from Firefox team </span></span><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=570341"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">here</span></span></a><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">.</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> </span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">Before I finish one quick update as per the </span></span><a href="http://developer.yahoo.com/blogs/ydn/posts/author/philip/"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">Philip Tellis</span></span></a><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> of Yahoo Performance team, in this recent blog </span></span><a href="http://developer.yahoo.com/blogs/ydn/posts/2010/07/boomerang_webtiming_api/"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">post</span></span></a></p>
<div class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;">, Boomerang has already updated the code to leverage IE 9 implementation of Web Timing API. Now you know why Boomerang is my favorite when it comes to JS instrumentation.</span></span></div>
<p><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> </p>
<p></span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="&quot;Times New Roman&quot;,&quot;serif&quot;;"><span style="small;"> </span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.globallogic.com/optimizing-aspnet-web-application-part-2-measuring-performance/feed</wfw:commentRss>
<enclosure url="http://www.fiddler2.com/fiddler/help/video/FiddlerQuickStart.wmv" length="9529358" type="video/x-ms-wmv" />
		</item>
		<item>
		<title>Optimizing ASP.NET web application - Part 1 (Let the journey begin)</title>
		<link>http://blogs.globallogic.com/optimizing-aspnet-web-application-part-1-let-the-journey-begin</link>
		<comments>http://blogs.globallogic.com/optimizing-aspnet-web-application-part-1-let-the-journey-begin#comments</comments>
		<pubDate>Sat, 19 Mar 2011 05:43:37 +0000</pubDate>
		<dc:creator>dhejov</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<category><![CDATA[Web 2.0]]></category>

		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[Fiddler]]></category>

		<category><![CDATA[Performance]]></category>

		<category><![CDATA[Performance Optimization]]></category>

		<guid isPermaLink="false">http://blogs.globallogic.com/?p=1089</guid>
		<description><![CDATA[“Website is too slow” how many of you have heard this complaint either from your manager or client or worst case from the end user. Fortunately I have heard this few times
General trend I have seen is that the dev team is pushed into a “stress + stretch” mode and project crash landing into the [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="small;"><span style="Calibri;">“<strong>Website is too slow</strong>” how many of you have heard this complaint either from your manager or client or worst case from the end user. Fortunately I have heard this few times<img src="http://www.mazeguy.net/expressive/huge.gif" alt="" /></span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="Calibri;"><span style="small;">General trend I have seen is that the dev team is pushed into a “stress + stretch” mode and project crash landing into the red zone and attracting lot of attention all for wrong reasons.</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="Calibri;"><span style="small;">From my experience before any analysis or troubleshoot the most pivotal task is to ask this simple question. “<strong>What is considered good website performance?</strong>” </span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="small;"><span style="Calibri;">Let me tell you this, it is a very tricky and tough question to answer and require some meticulous analysis to come up with a pragmatic performance matrix for a website. But then I even had client responding the next day with a simple answer “page load time of 1 sec for every webpage on the website” </span><span style="Wingdings;"><span style="Wingdings;">J</span></span><span style="Calibri;">. </span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="small;"><span style="Calibri;">Now I want to make a very critical differentiation of term “Poor Performance”. The approach of optimization will completely change based on the context where this term is used. Primarily there can be 2 most important contexts:</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="minor-latin;"><span style="small;">1.</span></span><span style="minor-bidi;">       </span><span style="small;"><span style="Calibri;"><span style="'Lucida Sans Unicode';">New website is performing poorly.</span></span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="minor-latin;"><span style="small;">2.</span></span><span style="minor-bidi;">       </span><span style="Calibri;"><span style="small;"><span style="'Lucida Sans Unicode';">High performing existing website started performing poorly.</span></span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="Calibri;"><span style="small;">When I refer to poor performance I will be referring to the first context. Although many of the techniques explained in the series can be also used when dealing with poor performance in second context if not already used.</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="Calibri;"><span style="small;">Before saying good bye to the second context I would like to very briefly explain the approach I use in this context. When dealing with the second context both investigation and optimization should happen in the following order:</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="small;"><span style="Calibri;">Hardware</span><span style="Wingdings;"><span style="Wingdings;">à</span></span><span style="Calibri;">OS</span><span style="Wingdings;"><span style="Wingdings;">à</span></span><span style="Calibri;">Server Application</span><span style="Wingdings;"><span style="Wingdings;">à</span></span><span style="Calibri;">Application</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="Calibri;"><span style="small;">For example if you are looking into poor database performance in the second context, the order would be:</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="small;"><span style="Calibri;">Physical machine</span><span style="Wingdings;"><span style="Wingdings;">à</span></span><span style="Calibri;">Windows OS</span><span style="Wingdings;"><span style="Wingdings;">à</span></span><span style="Calibri;">SQL Server</span><span style="Wingdings;"><span style="Wingdings;">à</span></span><span style="Calibri;">Database</span><span style="Wingdings;"><span style="Wingdings;">à</span></span><span style="Calibri;">Table</span><span style="Wingdings;"><span style="Wingdings;">à</span></span><span style="Calibri;">Query</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="Calibri;"><span style="small;">Although most of the time it is done in the reverse direction starting with optimization of queries which I never felt as a cost effective and efficient approach but then it is just my view.</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="Calibri;"><span style="small;">I am iterating the scope again to avoid any confusion, the beast we are trying to tame is poor performance of a new application.</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="Calibri;"><span style="small;"><strong>Where do we start?</strong></span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="Calibri;"><span style="small;">Again the general trend I have seen starts with team looking into queries, missing indexes, primarily looking for the problem in the DB. Whereas in some case team would look into the code to identify any possible scope for improvement or rectification of bottlenecks. </span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="Calibri;"><span style="small;">My answer to this question is simple “Start from where it is closest to the end user” i.e. from the browser.</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="Calibri;"><span style="small;">One aspect lot of us don’t realize is the fact that the time spend by the page to render itself on the browser has really gone up from those days of simple HTML. I have seen cases when browser render time of the page accounted for something in the range from 30% to 70% of the total page load time.</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="Calibri;"><span style="small;">Other reasons for starting from the browser are the fact that most of optimization techniques used at this level is simple to implement, agnostic of the application logic and improvement in the performance is experienced by the end users instantaneously.</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="Calibri;"><span style="small;">Now that we have decided where to start from what is the next step?</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="Calibri;"><span style="small;">Measure your performance, which we will cover in the next part of the series.</span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="minor-bidi;"><span style="small;"> </span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="minor-bidi;"><span style="small;"> <span style="AR-SA;"><a title="Permanent Link to Optimizing ASP.NET web application - Part 2 (Measuring Performance)" href="http://blogs.globallogic.com/optimizing-aspnet-web-application-part-2-measuring-performance"><span style="#800080;"><strong>Optimizing ASP.NET web application - Part 2 (Measuring Performance)</strong></span></a><strong> </strong></span></span></span></p>
<p class="MsoNoSpacing" style="0in 0in 0pt;"><span style="minor-bidi;"><span style="small;"><span style="AR-SA;"><span style="AR-SA;"><a href="http://blogs.globallogic.com/optimizing-aspnet-web-application-part-3a-aspnet-level-optimization-techniques"><span style="#800080;"><strong> Optimizing ASP.NET web application - Part 3a ASP.NET Level Optimization Techniques</strong></span></a></span></span></span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.globallogic.com/optimizing-aspnet-web-application-part-1-let-the-journey-begin/feed</wfw:commentRss>
		</item>
		<item>
		<title>Digital Media Breakfast Series in LA</title>
		<link>http://blogs.globallogic.com/digital-media-breakfast-series-in-la</link>
		<comments>http://blogs.globallogic.com/digital-media-breakfast-series-in-la#comments</comments>
		<pubDate>Wed, 24 Mar 2010 05:04:54 +0000</pubDate>
		<dc:creator>Sachin Saxena</dc:creator>
		
		<category><![CDATA[Global Product Development]]></category>

		<category><![CDATA[Web 2.0]]></category>

		<category><![CDATA[Agile]]></category>

		<category><![CDATA[Digital Media]]></category>

		<guid isPermaLink="false">http://blogs.globallogic.com/?p=980</guid>
		<description><![CDATA[Amazing talk by Colin McQuade on BSkyB journey. Talked about trends in Digital Media, Mobile, Agile and 3D! Talked about the importance of cultural/ mindset fit while picking Agile product development partner.
]]></description>
			<content:encoded><![CDATA[<p>Amazing talk by Colin McQuade on BSkyB journey. Talked about trends in Digital Media, Mobile, Agile and 3D! Talked about the importance of cultural/ mindset fit while picking Agile product development partner.</p>
<div id="attachment_981" class="wp-caption alignright" style="width: 310px"><a href="../wp-content/uploads/2010/09/event2.jpg"><img class="size-medium wp-image-981" src="../wp-content/uploads/2010/09/event2-300x199.jpg" alt="Sky TV’s Colin McQuade" width="300" height="199" /></a><p class="wp-caption-text">Sky TV’s Colin McQuade</p></div>
]]></content:encoded>
			<wfw:commentRss>http://blogs.globallogic.com/digital-media-breakfast-series-in-la/feed</wfw:commentRss>
		</item>
		<item>
		<title>cumulusIQ: The Knowledge Inflection Point</title>
		<link>http://blogs.globallogic.com/the-knowledge-inflection-point</link>
		<comments>http://blogs.globallogic.com/the-knowledge-inflection-point#comments</comments>
		<pubDate>Mon, 16 Nov 2009 02:47:39 +0000</pubDate>
		<dc:creator>Monty Kalsi</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[Web 2.0]]></category>

		<category><![CDATA[inflection]]></category>

		<category><![CDATA[KaaS]]></category>

		<category><![CDATA[knowledge]]></category>

		<guid isPermaLink="false">http://blogs.globallogic.com/?p=804</guid>
		<description><![CDATA[All knowledge is not equally useful all the time. Any particular piece of knowledge gets more valuable as you move closer to its application and diminishes more or less quickly thereafter....
When we speak about Knowledge as a Service℠  (KaaS) we are really talking about moving the point of knowledge acquisition as close as possible to the knowledge inflection point — without going beyond.  This is what distinguishes KaaS as a field as opposed to other kinds of knowledge services such as classroom teaching or scientific research. ]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal" style="120%;">From <a href="http://blog.cumulusiq.com/2009/10/the-knowledge-inflection-point.html" target="_self">cumulusIQ blog</a> &#8230;.</p>
<p class="MsoNormal" style="120%;"><span style="&quot;Arial&quot;,&quot;sans-serif&quot;;">All knowledge is not equally useful all the time. Any particular piece of knowledge gets more valuable as you move closer to its application and diminishes more or less quickly thereafter.<span> </span>If you graph the value of the knowledge as a curve &#8212; with utility along the y-axis and time along the x-axis, the change in direction of the slope from positive to negative might be considered the <em>knowledge inflection point</em>.<span> </span></span></p>
<p class="MsoNormal" style="120%;"><span style="&quot;Arial&quot;,&quot;sans-serif&quot;;"><span><br />
</span></span></p>
<p class="MsoNormal" style="120%;"><a href="http://blog.spinact.com/.a/6a00e55499485988330120a64054c4970c-pi"><img class="asset asset-image at-xid-6a00e55499485988330120a64054c4970c image-full " src="http://blog.spinact.com/.a/6a00e55499485988330120a64054c4970c-800wi" border="0" alt="Kip1" width="581" height="311" /></a></p>
<p class="MsoNormal" style="120%;"><span style="&quot;Arial&quot;,&quot;sans-serif&quot;;">When we speak about Knowledge as a Service</span><span style="&quot;Calibri&quot;,&quot;sans-serif&quot;;">℠</span><span style="&quot;Arial&quot;,&quot;sans-serif&quot;;"> </span><span style="&quot;Arial&quot;,&quot;sans-serif&quot;;"> (KaaS) we are really talking about moving the point of knowledge acquisition as close as possible to the knowledge inflection point — without going beyond.<span> </span>This is what distinguishes KaaS as a field as opposed to other kinds of knowledge services such as classroom teaching or scientific research.<span> </span>The fact that KaaS is modeled after SaaS is no accident, since a running software process might be considered a particular kind of knowledge, as <a href="http://blogs.forrester.com/vendor_strategy/2009/09/the-rise-of-the-collaborative-cloud.html">discussed recently by Forrester analyst Holger Kisker</a>.<span> </span>The fact that software is not self-aware is not the critical distinction.<span> </span>What is critical though &#8212; for both KaaS and SaaS &#8212; is this idea that getting close to, but not going beyond, the knowledge inflection point is what counts.</span></p>
<p class="MsoNormal" style="120%;"><span style="&quot;Arial&quot;,&quot;sans-serif&quot;;">There are lots of interesting observations to be made about knowledge inflection points.<span> </span>One is that any real world process &#8212; like implementing an IT system &#8212; can be viewed as a series of multiple knowledge inflection points.<span> </span>As you solve one problem, another emerges on the horizon &#8212; and your knowledge acquisition must rise to the occasion in time.<span> </span>Until the process lifecycle is complete, you must ride these successive “waves” successfully without falling off.</span></p>
<p><span style="&quot;Arial&quot;,&quot;sans-serif&quot;;">For more on the knowledge inflection point, and to see an example from the world of SAP customer support, check out our recent <a href="http://marketing.cumulusiq.com/Knowledge_as_a_Service">white paper here</a>.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.globallogic.com/the-knowledge-inflection-point/feed</wfw:commentRss>
		</item>
		<item>
		<title>The tale of two Webs</title>
		<link>http://blogs.globallogic.com/the-tale-of-two-webs</link>
		<comments>http://blogs.globallogic.com/the-tale-of-two-webs#comments</comments>
		<pubDate>Thu, 12 Nov 2009 20:11:24 +0000</pubDate>
		<dc:creator>Sachin Saxena</dc:creator>
		
		<category><![CDATA[Enterprise 2.0]]></category>

		<category><![CDATA[Marketing]]></category>

		<category><![CDATA[Technology]]></category>

		<category><![CDATA[Web 2.0]]></category>

		<guid isPermaLink="false">http://blogs.globallogic.com/?p=796</guid>
		<description><![CDATA[ Web 2.0 vs. Web 1.0 The tale of these two Webs is best told once we understand the meaning, importance and the differences between the following key words for each of the two versions of the web: 
* Communities * Content * Communication  *Conversations 
Communities: Humans are social creature and associating with a [...]]]></description>
			<content:encoded><![CDATA[<p><span style="14px;"> <strong>Web 2.0 vs. Web 1.0</strong> The tale of these two Webs is best told once we understand the meaning, importance and the differences between the following key words for each of the two versions of the web: </span></p>
<p><span style="14px;">* Communities * Content * Communication  *Conversations </span></p>
<p><span style="14px;"><strong>Communities</strong>: Humans are social creature and associating with a ‘tribe’ is a very basic instinct for most of us. We identify ourselves by the places where we were born or live, schools we attended, religious beliefs we practice, professions organization we belong to, companies we work for and a whole slew of such groupings. The groups can be professional or personal and everything in between. Web 1.0 was very informational centric and did not include the community aspect. It did not foster any sense of community, the sense of belonging. So in a sense Web 1.0 did very little to address one of the very basic human nature.</span></p>
<p><span style="14px;"><strong>Content</strong>: Content is king. However not all kings are created equals, there are emperors, kings and chiefs. Similarly all content is not created equal. In content world, one of the biggest differentiator is content creator. In the world of Web 1.0, because of the inherent cost related to content publishing and distribution, content was locked-up to the few. For example corporate marketing defined all out bound messaging. However, within any industry, groups or company there are leaders and experts, example company CTO or somebody who is an influencer in your group. Their voice and opinions are important to a more targeted group. The third type of content is the idle chat between friends, or a water cooler talk between co-workers, think Facebook. People have various personas, and there is place for all these types of conversation in each person’s life. </span></p>
<p><span style="14px;">Whereas Web 1.0 was mostly for the first persona of content creators, Web 2.0 covers all types of content. In the Web 2.0 world, Wikipedia replaced Encyclopedias, Corporate Wiki replaced the intranet and your LinkedIn post of “Tell your network what you are doing” and IM status replaced the Post-it notes of “Do not disturb” sign outside the cubicle. </span></p>
<p><span style="14px;"><strong>Communication</strong>: Communication is a two way dialog. In the real world it happens top down, bottom up, and sideways. The first version of the web was top down, talk only as it had no listen capability. In a sense it allowed for a very uninteresting monolog. Web 2.0 is about two way communication, it is about a dialog. </span></p>
<p><span style="14px;">It put people and their communities in the center of all the dialogs. In the first incarnation of the web, this interaction was left to the physical world. Communication is about collaboration and conversations. It is about linking, sharing and interacting. Web 2.0 provided a platform to do all of this. </span></p>
<p><span style="14px;">With so much content and so many conversations and no moderator, the problem of information overload became even more acute. Web 2.0 addressed this problem with a unique ‘wisdom of the crowds’ who provide the moderation by ‘following on twitter’, rating and ranking associated with both the content providers and their content. Comments, bookmarks, ‘..also bought’ (at Amazon), thumbs-up/ down, defined the features that link between relevant content to their communities and allowed them to have a meaningful conversation. </span></p>
<p><span style="14px;"><strong>What role has Web 2.0 played in giving rise to the era of blogging and to social networking?</strong> </span></p>
<p><span style="14px;">Some of the key Web 2.0 technologies include </span></p>
<p><span style="14px;">*Social Networking site </span></p>
<p><span style="14px;">*Wikis, Blogs &amp; Micro blog </span></p>
<p><span style="14px;">*Mash-ups, Video and Podcast </span></p>
<p><span style="14px;">There are five specific business objectives of most communication — to listen, to talk, to energize, to support, and to embrace. Individuals and companies are using Web 2.0 technologies to communicate with their customers, business partners, employees and their industry groups. Blogging and Social networking are two of the more widely adopted Web 2.0 technologies. </span></p>
<p><span style="14px;">Often time, the users for these tools are viewed as outside of the company, but the audience can very likely be your employees too. Initial adoption of these technologies was done by companies trying to sell directly to the consumer, but companies that have traditionally sold to the Fortune 2000 or to SMB are also starting to adopt ways to bring these tools into their portfolio. The initial adopters of these tools were people who were in the front end of the sales and marketing, but now applications are being developed that are using these tools to support internal and backend processes. Imagine the CEO of a company who wants to engage in ‘chat dialog’ with thousands of employees. Think of the CTO who wants to communicate his product/ architecture vision to the engineers while including constructive feedback from his entire team. These tools are the enablers of these conversations. </span></p>
<p><span style="14px;"><strong>So how has the rise of Web 2.0 affected business and changed the way people work.</strong> </span></p>
<p><span style="14px;">Web 2.0 is still in its infancy within most organizations. However it has the prospect of changing how marketing departments engages with prospects and customers, how product managers interact with internal and external stake holders, how hiring and recruitment is done, how training is delivered, or how customer support performs their activities today. For example, it is not uncommon that marketing updates their websites once a quarter or every six months with messages that are very carefully crafted but that is totally gibberish to most. It does not have to happen that way. There is no reason why training departments should only conduct instructor led courses that are conducted at prescheduled times that are inconvenient to all and topics that are relevant to few. </span></p>
<p><span style="14px;"><strong>Where is the web 2.0 heading</strong> </span></p>
<p><span style="14px;">The future is hard to predict. However, some places where Web 2.0 is most like to go next could be.. </span></p>
<p><span style="14px;">•Adoption of these tools within the enterprise. Companies shall start using these constructs to reduce the friction and increase the speed in how work is done. Some have labeled this as ‘Enterprise 2.0’. Today integration of the corporate tools such as email, documents etc. is missing. Addressing issues such as security, compliance, would be important before these tools get wider acceptance within enterprise. </span></p>
<p><span style="14px;">•Web 2.0 is very text oriented today. Video, animation, audio, mobile smart phones are some fairly unexplored areas in the web 2.0 world. </span></p>
<p><span style="14px;">•So far Web 2.0 is mostly about free to consumers. Rise of the private club, where members pay to participate or pay for premium services, B2B services is another area that is relatively unexplored. </span></p>
<p><!--Session data--></p>
<p><!--Session data--></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.globallogic.com/the-tale-of-two-webs/feed</wfw:commentRss>
		</item>
	</channel>
</rss>

