<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Span and div &#8211; stoimen&#039;s web log</title>
	<atom:link href="/tag/span-and-div/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>on web development</description>
	<lastBuildDate>Tue, 13 Feb 2018 08:18:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.0.3</generator>
	<item>
		<title>2xjQuery: Select a Selector</title>
		<link>/2010/09/24/2xjquery-select-a-selector/</link>
		<comments>/2010/09/24/2xjquery-select-a-selector/#comments</comments>
		<pubDate>Fri, 24 Sep 2010 08:23:58 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[Comparison of JavaScript frameworks]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[Ext]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[JavaScript programming language]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery javascript library]]></category>
		<category><![CDATA[jquery selectors]]></category>
		<category><![CDATA[Markup languages]]></category>
		<category><![CDATA[openlayers]]></category>
		<category><![CDATA[openlayers library]]></category>
		<category><![CDATA[Span and div]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[World Wide Web]]></category>

		<guid isPermaLink="false">/?p=1989</guid>
		<description><![CDATA[Selectors in jQuery If you&#8217;re familiar with jQuery you should already know what are selectors and how they work. However we&#8217;re used to get some DOM element with a specific selector, but actually sometimes you cannot select directly what you need. This is especially true when mixing more than one JavaScript libraries. In my case &#8230; <a href="/2010/09/24/2xjquery-select-a-selector/" class="more-link">Continue reading <span class="screen-reader-text">2xjQuery: Select a Selector</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/01/08/jquery-vs-pure-javascript/" rel="bookmark" title="jQuery vs. pure JavaScript">jQuery vs. pure JavaScript </a></li>
<li><a href="/2009/07/29/cancel-bubbling-on-element-click-with-jquery/" rel="bookmark" title="cancel bubbling on element click with jQuery">cancel bubbling on element click with jQuery </a></li>
<li><a href="/2009/11/02/ajax-in-jquery/" rel="bookmark" title="$.ajax in jQuery">$.ajax in jQuery </a></li>
<li><a href="/2009/04/01/jquery-accessing-a-child-element/" rel="bookmark" title="jQuery &#8211; accessing a child element">jQuery &#8211; accessing a child element </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>Selectors in jQuery</h2>
<p><a href="/wp-content/uploads/2010/09/jquery.png"><img class="alignleft size-full wp-image-1999" title="jquery" src="/wp-content/uploads/2010/09/jquery.png" alt="jQuery JavaScript Library" width="259" height="65" /></a></p>
<p>If you&#8217;re familiar with <a title="jQuery" href="http://jquery.com/" target="_blank">jQuery</a> you should already know what are selectors and how they work. However we&#8217;re used to get some DOM element with a specific selector, but actually sometimes you cannot select directly what you need. This is especially true when mixing more than one JavaScript libraries. In my case <a title="OpenLayers" href="http://openlayers.org/" target="_blank">OpenLayers</a> generated a vector layer and jQuery was supposed to change the vectors fill-color property.</p>
<p><a href="/wp-content/uploads/2010/09/openlayers.png"><img class="alignleft size-full wp-image-2000" title="openlayers" src="/wp-content/uploads/2010/09/openlayers.png" alt="OpenLayers" width="195" height="37" /></a></p>
<p>With the simple $(&#8216;path&#8217;) I easily got all vectors in the current document, but the problem was that I took them as text. Thus it came to me to use nested jQuery &#8211; $($(&#8216;selector&#8217;));</p>
<p>To describe what actually happened in my case, let me show you a breve example.</p>
<h2>Example</h2>
<p>Here&#8217;s a short HTML markup:</p>
<pre lang="html4strict">
<div><span>text text</span></div>

</pre>
<p>With jQuery I can select both the DIV and SPAN with the simple $(&#8216;div&#8217;) and $(&#8216;span&#8217;), but just for the example lets assume I&#8217;ve only the inner text of the DIV tag:</p>
<pre lang="javascript">$('div').html();
</pre>
<p>That was the case in the OpenLayers/jQuery problem. Now I can easily use another jQuery selector:</p>
<pre lang="javascript">$($('div').html());
</pre>
<p>This will return the same as $(&#8216;span&#8217;) &#8211; a jQuery object.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/01/08/jquery-vs-pure-javascript/" rel="bookmark" title="jQuery vs. pure JavaScript">jQuery vs. pure JavaScript </a></li>
<li><a href="/2009/07/29/cancel-bubbling-on-element-click-with-jquery/" rel="bookmark" title="cancel bubbling on element click with jQuery">cancel bubbling on element click with jQuery </a></li>
<li><a href="/2009/11/02/ajax-in-jquery/" rel="bookmark" title="$.ajax in jQuery">$.ajax in jQuery </a></li>
<li><a href="/2009/04/01/jquery-accessing-a-child-element/" rel="bookmark" title="jQuery &#8211; accessing a child element">jQuery &#8211; accessing a child element </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/09/24/2xjquery-select-a-selector/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CSS Priority: The Difference Between a.my-class and .my-class</title>
		<link>/2010/03/11/css-priority-the-difference-between-a-my-class-and-my-class/</link>
		<comments>/2010/03/11/css-priority-the-difference-between-a-my-class-and-my-class/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 14:58:28 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[Cascading Style Sheets]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[firebug]]></category>
		<category><![CDATA[Google Inc.]]></category>
		<category><![CDATA[Span and div]]></category>
		<category><![CDATA[Web design]]></category>

		<guid isPermaLink="false">/?p=1222</guid>
		<description><![CDATA[Do You Know What&#8217;s an Inefficient CSS Selector? Perhaps! I was curious how can inefficient selectors impact a page performance. To begin with this topic let me say that inefficient selector is referred usually as nested selector: div span div { border:1px solid red; } as you can see here there are three nested tags &#8230; <a href="/2010/03/11/css-priority-the-difference-between-a-my-class-and-my-class/" class="more-link">Continue reading <span class="screen-reader-text">CSS Priority: The Difference Between a.my-class and .my-class</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/02/04/css-effective-selector/" rel="bookmark" title="CSS effective selector">CSS effective selector </a></li>
<li><a href="/2010/01/30/optimizing-css-five-simple-steps/" rel="bookmark" title="Optimizing CSS. Five simple steps!">Optimizing CSS. Five simple steps! </a></li>
<li><a href="/2010/01/18/what-if-your-site-doesnt-use-all-of-the-css-selectors/" rel="bookmark" title="What if your site doesn&#8217;t use all of the CSS selectors?">What if your site doesn&#8217;t use all of the CSS selectors? </a></li>
<li><a href="/2010/02/15/css-selectors-new-look-over-them/" rel="bookmark" title="CSS selectors &#8211; new look over them">CSS selectors &#8211; new look over them </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>Do You Know What&#8217;s an Inefficient CSS Selector?</h2>
<p>Perhaps! I was curious how can inefficient selectors impact a page performance. To begin with this topic let me say that inefficient selector is referred usually as nested selector:</p>
<pre lang="css">div span div {
    border:1px solid red;
}
</pre>
<p>as you can see here there are three nested tags I use to reference the innermost div. If you&#8217;re wondering how you&#8217;d know about inefficient selectors &#8211; well there is a plugin for the <a title="Firebug" href="http://getfirebug.com/" target="_blank">Firebug</a> written by a Google team called <a title="Page Speed" href="http://code.google.com/speed/page-speed/" target="_blank">Page Speed</a> explaining which of your selectors are inefficient. See the image below.</p>
<p><a href="/wp-content/uploads/2010/03/css-selectors-inefficient1.png"><img class="aligncenter size-full wp-image-1273" title="css-selectors-inefficient" src="/wp-content/uploads/2010/03/css-selectors-inefficient1.png" alt="CSS Page Speed Inefficient Selectors" width="430" height="113" srcset="/wp-content/uploads/2010/03/css-selectors-inefficient1.png 430w, /wp-content/uploads/2010/03/css-selectors-inefficient1-300x78.png 300w" sizes="(max-width: 430px) 100vw, 430px" /></a></p>
<p>In the <a title="CSS Performance Demo" href="http://www.stoimen.com/projects/css.selectors.performance/" target="_blank">demo</a> page you can find what I was trying to achieve and you can play around with that code to measure by yourself the performance of the different selectors.</p>
<h2>So who&#8217;s faster? Nested, IDs or Classes?</h2>
<p>Actually its pretty though to say. Yet another surprise for me was to notice that the notation:</p>
<pre lang="css">div.my-class {}
</pre>
<p>was a bit slower than the marked as <em>&#8220;inefficient&#8221;</em> by Page Speed:</p>
<pre lang="css">div span div {}
</pre>
<p>Another good thing to mention is that there is a difference between div.my-class and .my-class</p>
<h2>Question&#8217;s answer &#8230;</h2>
<p>In fact <strong>div.my-class</strong> is always with a higher priority than <strong>.my-class</strong> even if you&#8217;ve the following code:</p>
<pre lang="css">div.my-class {
    border:1px solid red;
}

.my-class {
    border:1px solid blue;
}

div span div {
    border:1px solid black;
}
</pre>
<p>And the computed style for Firefox was &#8230;</p>
<p><a href="/wp-content/uploads/2010/03/css-selectors-code.png"><img class="aligncenter size-full wp-image-1274" title="css-selectors-code" src="/wp-content/uploads/2010/03/css-selectors-code.png" alt="CSS Selector Performance Computed Style" width="430" height="170" srcset="/wp-content/uploads/2010/03/css-selectors-code.png 430w, /wp-content/uploads/2010/03/css-selectors-code-300x118.png 300w" sizes="(max-width: 430px) 100vw, 430px" /></a></p>
<p>where &#8220;div span div&#8221; chain matches the same elements as the previous selectors, as you can see:</p>
<p><a href="/wp-content/uploads/2010/03/css-selectors-dom-view.png"><img class="aligncenter size-full wp-image-1275" title="css-selectors-dom-view" src="/wp-content/uploads/2010/03/css-selectors-dom-view.png" alt="CSS Selector DOM View" width="430" height="127" srcset="/wp-content/uploads/2010/03/css-selectors-dom-view.png 430w, /wp-content/uploads/2010/03/css-selectors-dom-view-300x88.png 300w" sizes="(max-width: 430px) 100vw, 430px" /></a></p>
<p>so even that <strong>div.my-class</strong> will be the most important and finally the element will get its red border! It does not depend only on where you put the CSS rules, but also on how they are defined.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/02/04/css-effective-selector/" rel="bookmark" title="CSS effective selector">CSS effective selector </a></li>
<li><a href="/2010/01/30/optimizing-css-five-simple-steps/" rel="bookmark" title="Optimizing CSS. Five simple steps!">Optimizing CSS. Five simple steps! </a></li>
<li><a href="/2010/01/18/what-if-your-site-doesnt-use-all-of-the-css-selectors/" rel="bookmark" title="What if your site doesn&#8217;t use all of the CSS selectors?">What if your site doesn&#8217;t use all of the CSS selectors? </a></li>
<li><a href="/2010/02/15/css-selectors-new-look-over-them/" rel="bookmark" title="CSS selectors &#8211; new look over them">CSS selectors &#8211; new look over them </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/03/11/css-priority-the-difference-between-a-my-class-and-my-class/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>HTML Tag Semantics. STRONG vs. B!</title>
		<link>/2010/03/11/html-tag-semantics-strong-vs-b/</link>
		<comments>/2010/03/11/html-tag-semantics-strong-vs-b/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 12:09:17 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Cross-platform software]]></category>
		<category><![CDATA[Curly bracket programming languages]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[Label]]></category>
		<category><![CDATA[Markup languages]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Procedural programming languages]]></category>
		<category><![CDATA[Singular they]]></category>
		<category><![CDATA[Span and div]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[web project]]></category>

		<guid isPermaLink="false">/?p=1246</guid>
		<description><![CDATA[Do You Use LABEL? Have you ever mentioned the existence of the LABEL tag? Have you ever used it? I guess the majority of us don&#8217;t. Let&#8217;s take a look of the following chunk of code: &#60;label&#62;username:&#60;/label&#62; &#60;input type="text" name="username" /&#62; It looks familiar to every web developer, but the most common usage in web &#8230; <a href="/2010/03/11/html-tag-semantics-strong-vs-b/" class="more-link">Continue reading <span class="screen-reader-text">HTML Tag Semantics. STRONG vs. B!</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/09/24/2xjquery-select-a-selector/" rel="bookmark" title="2xjQuery: Select a Selector">2xjQuery: Select a Selector </a></li>
<li><a href="/2010/01/12/faster-html-why-not/" rel="bookmark" title="Faster HTML! Why not?">Faster HTML! Why not? </a></li>
<li><a href="/2010/03/02/fast-way-to-manage-the-arabic-version-of-a-web-form/" rel="bookmark" title="Fast way to manage the Arabic version of a web form">Fast way to manage the Arabic version of a web form </a></li>
<li><a href="/2010/03/10/php-if-else-endif-statements/" rel="bookmark" title="PHP if-else-endif Statements">PHP if-else-endif Statements </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>Do You Use LABEL?</h2>
<p>Have you ever mentioned the existence of the <strong>LABEL</strong> tag? Have you ever used it? I guess the majority of us don&#8217;t. Let&#8217;s take a look of the following chunk of code:</p>
<pre lang="html4strict" escaped="true">&lt;label&gt;username:&lt;/label&gt; &lt;input type="text" name="username" /&gt;</pre>
<p>It looks familiar to every web developer, but the most common usage in web forms is:</p>
<pre lang="html4strict" escaped="true">&lt;div&gt;username:&lt;/div&gt;</pre>
<p>or</p>
<pre lang="html4strict" escaped="true">&lt;span&gt;username:&lt;/span&gt;</pre>
<h2>How Looks a LABEL Tag?</h2>
<p>In fact if you use LABEL for the form instead of DIV or SPAN you&#8217;ll get the exactly same result as layout, beside that most common usage is a DIV or SPAN in place of the forgotten LABEL?! Why is that?</p>
<blockquote style="text-align: center;"><p><a href="/wp-content/uploads/2010/03/label.vs_.span_.png"><img class="size-full wp-image-1258" title="label.vs.span" src="/wp-content/uploads/2010/03/label.vs_.span_.png" alt="html tags. Label vs Span" width="288" height="120" /></a><br />
Can you see the difference between LABEL and SPAN?</p></blockquote>
<p>For me the usage of DIV has become critically enormous. It may sound strange that there is a debate about the usage of one or another HTML tag, but don&#8217;t you think every little text label in a web project is surrounded by a DIV. Actually that makes clear that if you&#8217;d like to be semantically correct, than you should use LABEL.</p>
<p>The funny thing is that almost every project is loading its labels in a PHP array or object or whatever and there they are called &#8220;Labels&#8221;, but when it comes to HTML they are put into a DIVs.</p>
<h2>Why Semantics Matters?</h2>
<p>In fact this is important because this is really good for web robots. If this is not important for the human eye it is for a machine &#8220;eye&#8221;. That&#8217;s why there are two tags for bold text.</p>
<h2>STRONG vs. B</h2>
<p>You can see that most of the browsers display both tags exactly the same by default.</p>
<blockquote style="text-align:center"><p><a href="/wp-content/uploads/2010/03/bold.vs_.strong.png"><img class="aligncenter size-full wp-image-1265" title="bold.vs.strong" src="/wp-content/uploads/2010/03/bold.vs_.strong.png" alt="Bold vs Strong HTML tags" width="177" height="39" /></a></p></blockquote>
<p>Why&#8217;s that? Because STRONG is semantically more important than &lt;B&gt;.</p>
<p>So if you want to make a text simply looking bold, wrap it in &lt;B&gt;, but if you want to make it important both for the human eye and for the machines, than use STRONG.</p>
<p><em><strong>Source:</strong> complete <a title="HTML tag semantics demo" href="http://www.stoimen.com/projects/html.tag.semantics/" target="_blank">demo</a>.</em></p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/09/24/2xjquery-select-a-selector/" rel="bookmark" title="2xjQuery: Select a Selector">2xjQuery: Select a Selector </a></li>
<li><a href="/2010/01/12/faster-html-why-not/" rel="bookmark" title="Faster HTML! Why not?">Faster HTML! Why not? </a></li>
<li><a href="/2010/03/02/fast-way-to-manage-the-arabic-version-of-a-web-form/" rel="bookmark" title="Fast way to manage the Arabic version of a web form">Fast way to manage the Arabic version of a web form </a></li>
<li><a href="/2010/03/10/php-if-else-endif-statements/" rel="bookmark" title="PHP if-else-endif Statements">PHP if-else-endif Statements </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/03/11/html-tag-semantics-strong-vs-b/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Faster HTML! Why not?</title>
		<link>/2010/01/12/faster-html-why-not/</link>
		<comments>/2010/01/12/faster-html-why-not/#respond</comments>
		<pubDate>Tue, 12 Jan 2010 06:08:08 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[DEFLATE]]></category>
		<category><![CDATA[Form]]></category>
		<category><![CDATA[Gzip]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[sick minded web developers]]></category>
		<category><![CDATA[Span and div]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[web browsers]]></category>
		<category><![CDATA[web developers]]></category>
		<category><![CDATA[Web page]]></category>
		<category><![CDATA[web page optimization]]></category>
		<category><![CDATA[web server]]></category>

		<guid isPermaLink="false">/?p=875</guid>
		<description><![CDATA[Although I’ve read so many articles about web page optimization there’s not so much about optimizing HTML. Why? Maybe because nobody things that the HTML source of a page can be optimized or the optimization of it cannot bring some benefit to the page load experience. I don’t thing so. If something can be optimized, &#8230; <a href="/2010/01/12/faster-html-why-not/" class="more-link">Continue reading <span class="screen-reader-text">Faster HTML! Why not?</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/03/11/html-tag-semantics-strong-vs-b/" rel="bookmark" title="HTML Tag Semantics. STRONG vs. B!">HTML Tag Semantics. STRONG vs. B! </a></li>
<li><a href="/2010/01/14/optimizing-openlayers-make-it-smaller-and-faster/" rel="bookmark" title="Optimizing OpenLayers. Make it smaller and faster!">Optimizing OpenLayers. Make it smaller and faster! </a></li>
<li><a href="/2010/07/17/send-html-mails-with-zend_mail/" rel="bookmark" title="Send Html Mails with Zend_Mail">Send Html Mails with Zend_Mail </a></li>
<li><a href="/2010/08/03/html-tags/" rel="bookmark" title="HTML Tags: &lt;base&gt;">HTML Tags: &lt;base&gt; </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>Although I’ve read so many articles about web page optimization there’s not so much about optimizing HTML.</p>
<h2>Why?</h2>
<p>Maybe because nobody things that the HTML source of a page can be optimized or the optimization of it cannot bring some benefit to the page load experience. I don’t thing so. If something can be optimized, even if this does not give you so much, why you shouldn’t do it?</p>
<h2>How to optimize such thing as HTML?</h2>
<p>Well there are few things you should do and other that can speed up a little bit but you should not.</p>
<h3>1. Enable gzip</h3>
<p>What is gzip? Well in breve everything the server generates is sent back to the client in text format. You’ve to possibilities to send it. Either compressed or uncompressed. As you may guess the compressed format is a lot faster than uncompressed. In fact to make it work that way you’d need to enable gzip which is supported by the web server. In the case of Apache web server this can be done by enabling mod_deflate. Take a look of mod_deflated and mod_inflate. This two modules gives you the possibility to make your site a lot faster and the good news is that this is done without a single line change. The bad news, as always there’s a bad news, is that sometimes this cannot help a visitor, simply because his browser doesn’t support such corresponding with the server. According to a research I’ve read recently almost 15% of the web browsers doesn’t support gzip. Sometimes the reason is old browser versions, sometimes because the state policy doesn’t allow it. However this is the first thing you should do to speed up your HTML even it is not related directly to HTML scripts. By the way this will speed up everything which is sent back to the client, especially CSS and JavaScript files and in the case of JavaScript this can improve dramatically the user experience.<span id="more-875"></span></p>
<h3>2. Use div elements instead of tables when possible.</h3>
<p>This is the second thing you can do to speed up your site. The simple reason to do that is because the DIV element doesn’t need so much markup as a TABLE element. When widely used in a page &#8211; imaging thousands of tables this can be a disaster. Remember the first thing is to make the text you send to the server as small as possible. In that point I should say that not only the tables to div switch is enough. Always prefer smaller tags and constructions. This is a bit difficult. Some experienced web developers can construct the same page with less HTML markup than newbies, but that depends of your level of experience.</p>
<h3>3. Make it ugly &#8211; just to spend some space.</h3>
<p>Your code is beautifully organized and when viewing the source everyone is excited! That was a mistake I used to make in my early projects. Why we thing somebody will take a look of the source code? Why we thing somebody’s using view-source option? Because we’re sick minded web developers. Nobody cares about your well organized source code. Normal users don’t look at it! Forget about beauty! As you may remember &#8211; you should spend all the extra spaces you send to the browser. Well if well organized the source code is full of tabulations, new lines and spaces. This is not good! Well if gzip is enabled they may be spent to the client, but if not? Stop writing beautiful HTML. The first task is to make it readable and maintainable.</p>
<h3>4. Don’t use inline styling</h3>
<p>This cannot be cached by the browser, is difficult to maintain and is &#8211; ugly! Yeah don’t use inline styles it makes your markup larger, which yet again is bad and is difficult to maintain. Write everything in CSS files, include them from the outside and setup only the classes you need.</p>
<h3>5. Make it maintainable</h3>
<p>Although its important to make the HTML as small as possible, sometimes that means to make it as ugly as possible and that brings the enemy number one &#8211; unmaintainable code. After a while the change of that code is technically impossible. So use all these techniques with something in mind &#8211; make it maintainable even if that will sacrifice some optimization benefits.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/03/11/html-tag-semantics-strong-vs-b/" rel="bookmark" title="HTML Tag Semantics. STRONG vs. B!">HTML Tag Semantics. STRONG vs. B! </a></li>
<li><a href="/2010/01/14/optimizing-openlayers-make-it-smaller-and-faster/" rel="bookmark" title="Optimizing OpenLayers. Make it smaller and faster!">Optimizing OpenLayers. Make it smaller and faster! </a></li>
<li><a href="/2010/07/17/send-html-mails-with-zend_mail/" rel="bookmark" title="Send Html Mails with Zend_Mail">Send Html Mails with Zend_Mail </a></li>
<li><a href="/2010/08/03/html-tags/" rel="bookmark" title="HTML Tags: &lt;base&gt;">HTML Tags: &lt;base&gt; </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/01/12/faster-html-why-not/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery live() vs bind() performance</title>
		<link>/2009/12/30/jquery-live-vs-bind-performance/</link>
		<comments>/2009/12/30/jquery-live-vs-bind-performance/#respond</comments>
		<pubDate>Wed, 30 Dec 2009 15:27:06 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[Application programming interfaces]]></category>
		<category><![CDATA[Document Object Model]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[HTML element]]></category>
		<category><![CDATA[JavaScript programming language]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[Span and div]]></category>

		<guid isPermaLink="false">/?p=841</guid>
		<description><![CDATA[1. What is event delegation in JavaScript? To start with some example let&#8217;s assume that there is one DIV element with 100 A tags inside. If you assign event to every A tag that as you may know slowes down your browser. That&#8217;s a problem because sometimes that can happen, even with more than one &#8230; <a href="/2009/12/30/jquery-live-vs-bind-performance/" class="more-link">Continue reading <span class="screen-reader-text">jQuery live() vs bind() performance</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2009/10/08/jquery-the-difference-between-mouseout-and-mouseleave/" rel="bookmark" title="jQuery: the difference between mouseout and mouseleave">jQuery: the difference between mouseout and mouseleave </a></li>
<li><a href="/2009/07/29/cancel-bubbling-on-element-click-with-jquery/" rel="bookmark" title="cancel bubbling on element click with jQuery">cancel bubbling on element click with jQuery </a></li>
<li><a href="/2009/05/25/remove-dom-element-with-jquery/" rel="bookmark" title="Remove DOM Element with JQuery">Remove DOM Element with JQuery </a></li>
<li><a href="/2009/04/01/jquery-accessing-a-child-element/" rel="bookmark" title="jQuery &#8211; accessing a child element">jQuery &#8211; accessing a child element </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>1. What is event delegation in JavaScript?</h2>
<p>To start with some example let&#8217;s assume that there is one DIV element with 100 A tags inside. If you assign event to every A tag that as you may know slowes down your browser. That&#8217;s a problem because sometimes that can happen, even with more than one hundred A tags. Imagine you&#8217;ve a map with one thousand markers, which are A tags. Attaching events slowes down the browser, because every of these A tags bubbles the event that has been fired. And that makes your CPU to make thousands of calculations. Of course you can avoid this problem with a simple technique. Just attach one single event on the container DIV element. Thus you can check if some child of the DIV element has been the target of the event. This makes the browser to breath.<span id="more-841"></span></p>
<h2>2. How event delegation is implemented in jQuery &#8211; $.live()</h2>
<p>In jQuery the so called event delegation is done by the $.live() method. As you may see in the doc pages of jQuery thus you can attach events on a selected element even before that element exists into the DOM. Just because the attached event is on the parent element, and once there are more and more elements attached to it as children, thay behave the same way as those attached before.</p>
<blockquote>
<pre>Example:
$('div &gt; a').live('click', doSomething);</pre>
</blockquote>
<h2>3. bind with $.bind() or $.click, $.mousemove &#8230;</h2>
<p>More common use in jQuery is to attach elements with $.bind or it&#8217;s shortcus $.click, $.mousemove &#8230; etc. The problem is that you have to call them again and again after you add more and more elements to the DOM, because this attach events to the matched elements. Normally when you add more elements they don&#8217;t have any event attached to.</p>
<blockquote>
<pre>Example:
$('div &gt; a').click(doSomething);
// this example does exactly the same thing as the one above,
// but applied on 1000 tags is much slower!</pre>
</blockquote>
<h2>4. Performance</h2>
<p>Of course the performance is better with $.live, but be carefull when playing around with those methods. See more performance results <a href="http://www.ravelrumba.com/blog/event-delegation-jquery-performance/" target="_blank">here</a>.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2009/10/08/jquery-the-difference-between-mouseout-and-mouseleave/" rel="bookmark" title="jQuery: the difference between mouseout and mouseleave">jQuery: the difference between mouseout and mouseleave </a></li>
<li><a href="/2009/07/29/cancel-bubbling-on-element-click-with-jquery/" rel="bookmark" title="cancel bubbling on element click with jQuery">cancel bubbling on element click with jQuery </a></li>
<li><a href="/2009/05/25/remove-dom-element-with-jquery/" rel="bookmark" title="Remove DOM Element with JQuery">Remove DOM Element with JQuery </a></li>
<li><a href="/2009/04/01/jquery-accessing-a-child-element/" rel="bookmark" title="jQuery &#8211; accessing a child element">jQuery &#8211; accessing a child element </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2009/12/30/jquery-live-vs-bind-performance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
