<?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>stoimen.com/blog</title>
	<atom:link href="http://www.stoimen.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.stoimen.com/blog</link>
	<description>web developing</description>
	<lastBuildDate>Sun, 21 Mar 2010 06:35:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>JavaScript Comparision Snippet</title>
		<link>http://www.stoimen.com/blog/2010/03/21/javascript-comparision-snippet/</link>
		<comments>http://www.stoimen.com/blog/2010/03/21/javascript-comparision-snippet/#comments</comments>
		<pubDate>Sun, 21 Mar 2010 06:35:23 +0000</pubDate>
		<dc:creator>Stoimen</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[compare]]></category>
		<category><![CDATA[operators]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://www.stoimen.com/blog/?p=1371</guid>
		<description><![CDATA[== vs. ===
I know this is really for beginners, but have you ever asked yourself what are the differences between == and === when comparing in JavaScript, and when to use it? Here&#8217;s an example:

var a = false;
alert&#40;a === 0&#41;; // prints false

That&#8217;s false. Even when both the zero and the variable are faulty the [...]


Related posts:<ol><li><a href='http://www.stoimen.com/blog/2009/03/09/flex-javascript-communcation-example/' rel='bookmark' title='Permanent Link: Flex Javascript communcation example'>Flex Javascript communcation example</a></li>
<li><a href='http://www.stoimen.com/blog/2010/02/12/how-to-detect-a-variable-existence-in-javascript/' rel='bookmark' title='Permanent Link: How to detect a variable existence in JavaScript?'>How to detect a variable existence in JavaScript?</a></li>
<li><a href='http://www.stoimen.com/blog/2009/07/08/javascript-closures-in-brief/' rel='bookmark' title='Permanent Link: JavaScript closures in brief'>JavaScript closures in brief</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<h2>== vs. ===</h2>
<p>I know this is really for beginners, but have you ever asked yourself what are the differences between <strong>==</strong> and <strong>===</strong> when comparing in JavaScript, and when to use it? Here&#8217;s an example:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> a <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>a <span style="color: #339933;">===</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// prints false</span></pre></div></div>

<p>That&#8217;s false. Even when both the zero and the variable are faulty the entire operation is false. Because the 0 is a number and the variable a is boolean, therefore their different types give us the answer. If there was a comparision only with == the result would be true:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> a <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>a <span style="color: #339933;">==</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// prints true</span></pre></div></div>

<p>It&#8217;s good when you expect some variable to match certain type to compare with ===. So the correct code is:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> a <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>a <span style="color: #339933;">===</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// prints true</span></pre></div></div>

<p>Here the type of a compares with boolean. See the complete <a href="http://www.stoimen.com/projects/javascript.comparision/" target="_blank">demo</a>.</p>


<p>Related posts:<ol><li><a href='http://www.stoimen.com/blog/2009/03/09/flex-javascript-communcation-example/' rel='bookmark' title='Permanent Link: Flex Javascript communcation example'>Flex Javascript communcation example</a></li>
<li><a href='http://www.stoimen.com/blog/2010/02/12/how-to-detect-a-variable-existence-in-javascript/' rel='bookmark' title='Permanent Link: How to detect a variable existence in JavaScript?'>How to detect a variable existence in JavaScript?</a></li>
<li><a href='http://www.stoimen.com/blog/2009/07/08/javascript-closures-in-brief/' rel='bookmark' title='Permanent Link: JavaScript closures in brief'>JavaScript closures in brief</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.stoimen.com/blog/2010/03/21/javascript-comparision-snippet/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>OpenLayers Can Be Faster!</title>
		<link>http://www.stoimen.com/blog/2010/03/19/openlayers-can-be-faster/</link>
		<comments>http://www.stoimen.com/blog/2010/03/19/openlayers-can-be-faster/#comments</comments>
		<pubDate>Fri, 19 Mar 2010 09:22:35 +0000</pubDate>
		<dc:creator>Stoimen</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[Geography]]></category>
		<category><![CDATA[Keyhole Markup Language]]></category>
		<category><![CDATA[openlayers]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[Web mapping]]></category>

		<guid isPermaLink="false">http://www.stoimen.com/blog/?p=1364</guid>
		<description><![CDATA[Put All The Markers at Once!
The way OpenLayers puts markers on the stage is fine when they are not so much, but once you need more than 100, the library&#8217;s solution is not good. The question is is there a way to put all the markers faster than the built in method.
Yes, There is a [...]


Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/02/08/openlayers-extreme-optimization-cut-compress-and-deploy/' rel='bookmark' title='Permanent Link: OpenLayers extreme optimization. Cut, compress and deploy!'>OpenLayers extreme optimization. Cut, compress and deploy!</a></li>
<li><a href='http://www.stoimen.com/blog/2010/02/09/optimizing-openlayers-speed-up-markers-load-time/' rel='bookmark' title='Permanent Link: Optimizing OpenLayers. Speed up markers load time!'>Optimizing OpenLayers. Speed up markers load time!</a></li>
<li><a href='http://www.stoimen.com/blog/2010/01/14/optimizing-openlayers-make-it-smaller-and-faster/' rel='bookmark' title='Permanent Link: Optimizing OpenLayers. Make it smaller and faster!'>Optimizing OpenLayers. Make it smaller and faster!</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<h2>Put All The Markers at Once!</h2>
<p>The way OpenLayers puts markers on the stage is fine when they are not so much, but once you need more than 100, the library&#8217;s solution is not good. The question is is there a way to put all the markers faster than the built in method.</p>
<h2>Yes, There is a Way to Speed Up Markers Load</h2>
<p>I once wrote about how to speed up markers on <a title="OpenLayers" href="http://openlayers.org/" target="_blank">OpenLayers</a>, it is clear that my decision was to concatenate the DOM elements like a string after I&#8217;ve generated all the markers as markup with innerHTML as it&#8217;s faster than appendChild. The only question left is how to convert Longitude/Latitude pair in pixels.</p>
<h2>The Answer&#8217;s Given by OpenLayers</h2>
<p>There is a method called <strong>getLayerPxFromLonLat()</strong> which do the job. Let me show you a snippet:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">ll <span style="color: #339933;">=</span> map.<span style="color: #660066;">getLayerPxFromLonLat</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> OpenLayers.<span style="color: #660066;">LonLat</span><span style="color: #009900;">&#40;</span>lon<span style="color: #339933;">,</span>lat<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>ll<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>You can see what&#8217;s inside the ll object. You can now reference the pixel as ll.y and ll.x.</p>


<p>Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/02/08/openlayers-extreme-optimization-cut-compress-and-deploy/' rel='bookmark' title='Permanent Link: OpenLayers extreme optimization. Cut, compress and deploy!'>OpenLayers extreme optimization. Cut, compress and deploy!</a></li>
<li><a href='http://www.stoimen.com/blog/2010/02/09/optimizing-openlayers-speed-up-markers-load-time/' rel='bookmark' title='Permanent Link: Optimizing OpenLayers. Speed up markers load time!'>Optimizing OpenLayers. Speed up markers load time!</a></li>
<li><a href='http://www.stoimen.com/blog/2010/01/14/optimizing-openlayers-make-it-smaller-and-faster/' rel='bookmark' title='Permanent Link: Optimizing OpenLayers. Make it smaller and faster!'>Optimizing OpenLayers. Make it smaller and faster!</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.stoimen.com/blog/2010/03/19/openlayers-can-be-faster/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Mobile Internet Users are Getting More Important</title>
		<link>http://www.stoimen.com/blog/2010/03/18/mobile-internet-users-are-getting-more-important/</link>
		<comments>http://www.stoimen.com/blog/2010/03/18/mobile-internet-users-are-getting-more-important/#comments</comments>
		<pubDate>Thu, 18 Mar 2010 08:17:29 +0000</pubDate>
		<dc:creator>Stoimen</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[.mobi]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Internet Mobile It]]></category>
		<category><![CDATA[Mobile advertising]]></category>
		<category><![CDATA[mobile device]]></category>
		<category><![CDATA[Mobile Internet]]></category>
		<category><![CDATA[Mobile phone]]></category>
		<category><![CDATA[mobile phones]]></category>
		<category><![CDATA[Mobile telecommunications]]></category>
		<category><![CDATA[Mobile Web]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[Windows Mobile]]></category>
		<category><![CDATA[Wireless]]></category>

		<guid isPermaLink="false">http://www.stoimen.com/blog/?p=1354</guid>
		<description><![CDATA[Internet Mobile
It isn&#8217;t strange that the internet is becoming more and more mobile. When it matters to news sites I think most of the mobile versions are better than the &#8220;desktop&#8221; versions of the site. Take a look at Huffingtonpost.com or LeMonde.fr.
Mobile Ads
The first thing that makes impression when comparing both mobile and desktop versions [...]


Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/03/17/stop-coding-iphone-apps-begin-with-html5-mobile-sites/' rel='bookmark' title='Permanent Link: Stop Coding iPhone Apps, Begin with HTML5 Mobile Sites'>Stop Coding iPhone Apps, Begin with HTML5 Mobile Sites</a></li>
<li><a href='http://www.stoimen.com/blog/2010/03/09/php-detecting-mobile-device/' rel='bookmark' title='Permanent Link: PHP: detecting mobile device'>PHP: detecting mobile device</a></li>
<li><a href='http://www.stoimen.com/blog/2010/03/10/change-the-viewport-be-ready-for-the-iphone/' rel='bookmark' title='Permanent Link: Change the Viewport, be Ready for the iPhone!'>Change the Viewport, be Ready for the iPhone!</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<h2>Internet Mobile</h2>
<p>It isn&#8217;t strange that the internet is becoming more and more mobile. When it matters to news sites I think most of the mobile versions are better than the &#8220;desktop&#8221; versions of the site. Take a look at <a title="Huffingtonpost" href="http://www.huffingtonpost.com/" target="_blank">Huffingtonpost.com</a> or <a title="Le Monde Fr" href="http://www.lemonde.fr/" target="_blank">LeMonde.fr</a>.</p>
<h2>Mobile Ads</h2>
<p>The first thing that makes impression when comparing both mobile and desktop versions of a site is the layout. Of course the lack of ads on the mobile version, or if not the absolute lack at least the small number of appearing ads, seems to be quite pleasant.</p>
<p>The thing is that as the web grow and as the web 2.0 is becoming a reality most of us will prefer to use it on a mobile device, just because it&#8217;s</p>
<ol>
<li>easier to use</li>
<li>easier to find</li>
<li>easier to follow</li>
</ol>
<p>Here&#8217;s a nice example of what mobile phones are now.<a style="margin: 0 auto;" href="http://www.stoimen.com/blog/wp-content/uploads/2010/03/mobile-market-share.gif"><img class="aligncenter size-medium wp-image-1357" title="Mobile Market Share 2010" src="http://www.stoimen.com/blog/wp-content/uploads/2010/03/mobile-market-share-300x181.gif" alt="" width="430" height="281" /></a></p>
<p>Now lets take a look on how the mobile web will grow in the near future.</p>
<p><a style="margin: 0 auto;" href="http://www.stoimen.com/blog/wp-content/uploads/2010/03/3687.gif"><img class="aligncenter size-full wp-image-1358" title="Mobile Internet Users Chart" src="http://www.stoimen.com/blog/wp-content/uploads/2010/03/3687.gif" alt="" width="260" height="200" /></a></p>
<p>That graphics describe quite well what will happen in the upcoming years. Is there now a question: <em><strong>should I make a mobile version of my site?</strong></em></p>


<p>Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/03/17/stop-coding-iphone-apps-begin-with-html5-mobile-sites/' rel='bookmark' title='Permanent Link: Stop Coding iPhone Apps, Begin with HTML5 Mobile Sites'>Stop Coding iPhone Apps, Begin with HTML5 Mobile Sites</a></li>
<li><a href='http://www.stoimen.com/blog/2010/03/09/php-detecting-mobile-device/' rel='bookmark' title='Permanent Link: PHP: detecting mobile device'>PHP: detecting mobile device</a></li>
<li><a href='http://www.stoimen.com/blog/2010/03/10/change-the-viewport-be-ready-for-the-iphone/' rel='bookmark' title='Permanent Link: Change the Viewport, be Ready for the iPhone!'>Change the Viewport, be Ready for the iPhone!</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.stoimen.com/blog/2010/03/18/mobile-internet-users-are-getting-more-important/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Stop Coding iPhone Apps, Begin with HTML5 Mobile Sites</title>
		<link>http://www.stoimen.com/blog/2010/03/17/stop-coding-iphone-apps-begin-with-html5-mobile-sites/</link>
		<comments>http://www.stoimen.com/blog/2010/03/17/stop-coding-iphone-apps-begin-with-html5-mobile-sites/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 14:55:45 +0000</pubDate>
		<dc:creator>Stoimen</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[app]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[mobile site]]></category>
		<category><![CDATA[ppk]]></category>
		<category><![CDATA[smart phones]]></category>

		<guid isPermaLink="false">http://www.stoimen.com/blog/?p=1347</guid>
		<description><![CDATA[PPK is right! Stop developing everything as a iPhone app. First that doesn&#8217;t work on any device except iPhone and it&#8217;s difficult to maintain. In reverse you should begin doing your mobile web site version. Hopefully with HTML5.
Do as Twitter did &#8230; or you&#8217;d be looking at http://m.digg.com &#8211; that&#8217;s the right way.


Related posts:Change the [...]


Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/03/10/change-the-viewport-be-ready-for-the-iphone/' rel='bookmark' title='Permanent Link: Change the Viewport, be Ready for the iPhone!'>Change the Viewport, be Ready for the iPhone!</a></li>
<li><a href='http://www.stoimen.com/blog/2010/03/18/mobile-internet-users-are-getting-more-important/' rel='bookmark' title='Permanent Link: Mobile Internet Users are Getting More Important'>Mobile Internet Users are Getting More Important</a></li>
<li><a href='http://www.stoimen.com/blog/2010/03/09/php-detecting-mobile-device/' rel='bookmark' title='Permanent Link: PHP: detecting mobile device'>PHP: detecting mobile device</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a title="HTML5 apps" href="http://www.quirksmode.org/blog/archives/2010/03/html5_apps.html" target="_blank">PPK</a> is right! Stop developing everything as a iPhone app. First that doesn&#8217;t work on any device except iPhone and it&#8217;s difficult to maintain. In reverse you should begin doing your mobile web site version. Hopefully with HTML5.</p>
<p>Do as <a title="twitter" href="http://twitter.com" target="_blank">Twitter</a> did &#8230; or you&#8217;d be looking at <a title="Mobile Digg" href="http://m.digg.com" target="_blank">http://m.digg.com</a> &#8211; that&#8217;s the right way.</p>


<p>Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/03/10/change-the-viewport-be-ready-for-the-iphone/' rel='bookmark' title='Permanent Link: Change the Viewport, be Ready for the iPhone!'>Change the Viewport, be Ready for the iPhone!</a></li>
<li><a href='http://www.stoimen.com/blog/2010/03/18/mobile-internet-users-are-getting-more-important/' rel='bookmark' title='Permanent Link: Mobile Internet Users are Getting More Important'>Mobile Internet Users are Getting More Important</a></li>
<li><a href='http://www.stoimen.com/blog/2010/03/09/php-detecting-mobile-device/' rel='bookmark' title='Permanent Link: PHP: detecting mobile device'>PHP: detecting mobile device</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.stoimen.com/blog/2010/03/17/stop-coding-iphone-apps-begin-with-html5-mobile-sites/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jQuery cssText Helps You Improve Browser Reflows</title>
		<link>http://www.stoimen.com/blog/2010/03/17/jquery-csstext-helps-you-improve-browser-reflows/</link>
		<comments>http://www.stoimen.com/blog/2010/03/17/jquery-csstext-helps-you-improve-browser-reflows/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 08:32:17 +0000</pubDate>
		<dc:creator>Stoimen</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[cssText]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[reflow]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://www.stoimen.com/blog/?p=1343</guid>
		<description><![CDATA[cssText
You know you can manage to redraw an element with single browser reflow. Instead of using .style.property &#8230; you can simply add all CSS properties you&#8217;d like to change with simply appending to style.cssText property.

var csstxt = $&#40;'#selector'&#41;.css&#40;'cssText'&#41; + ';top:100;left:100;border:1px solid red;color:#f00;';
$&#40;'#selector'&#41;.css&#40;'cssText', csstxt&#41;;

That code is a replacement for

$&#40;'#selector'&#41;.css&#40;&#123;
   left : '100px',
   [...]


Related posts:<ol><li><a href='http://www.stoimen.com/blog/2009/12/23/csstext-and-how-it-can-be-very-very-useful/' rel='bookmark' title='Permanent Link: cssText and how it can be very very useful'>cssText and how it can be very very useful</a></li>
<li><a href='http://www.stoimen.com/blog/2009/11/04/jquery-css-selectors-change-one-or-more-css-properties/' rel='bookmark' title='Permanent Link: jQuery CSS selectors. Change one or more CSS properties!'>jQuery CSS selectors. Change one or more CSS properties!</a></li>
<li><a href='http://www.stoimen.com/blog/2010/03/11/css-priority-the-difference-between-a-my-class-and-my-class/' rel='bookmark' title='Permanent Link: CSS Priority: The Difference Between a.my-class and .my-class'>CSS Priority: The Difference Between a.my-class and .my-class</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<h2>cssText</h2>
<p>You know you can manage to redraw an element with single browser <em>reflow</em>. Instead of using .style.property &#8230; you can simply add all CSS properties you&#8217;d like to change with simply appending to <em>style.cssText</em> property.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> csstxt <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#selector'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'cssText'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">';top:100;left:100;border:1px solid red;color:#f00;'</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#selector'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'cssText'</span><span style="color: #339933;">,</span> csstxt<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>That code is a replacement for</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#selector'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
   left <span style="color: #339933;">:</span> <span style="color: #3366CC;">'100px'</span><span style="color: #339933;">,</span>
   top <span style="color: #339933;">:</span> <span style="color: #3366CC;">'100px'</span><span style="color: #339933;">,</span>
   border <span style="color: #339933;">:</span> <span style="color: #3366CC;">'1px solid red'</span><span style="color: #339933;">,</span>
   color <span style="color: #339933;">:</span> <span style="color: #3366CC;">'#f00'</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>enjoy!</p>


<p>Related posts:<ol><li><a href='http://www.stoimen.com/blog/2009/12/23/csstext-and-how-it-can-be-very-very-useful/' rel='bookmark' title='Permanent Link: cssText and how it can be very very useful'>cssText and how it can be very very useful</a></li>
<li><a href='http://www.stoimen.com/blog/2009/11/04/jquery-css-selectors-change-one-or-more-css-properties/' rel='bookmark' title='Permanent Link: jQuery CSS selectors. Change one or more CSS properties!'>jQuery CSS selectors. Change one or more CSS properties!</a></li>
<li><a href='http://www.stoimen.com/blog/2010/03/11/css-priority-the-difference-between-a-my-class-and-my-class/' rel='bookmark' title='Permanent Link: CSS Priority: The Difference Between a.my-class and .my-class'>CSS Priority: The Difference Between a.my-class and .my-class</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.stoimen.com/blog/2010/03/17/jquery-csstext-helps-you-improve-browser-reflows/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>JavaScript Zen</title>
		<link>http://www.stoimen.com/blog/2010/03/17/javascript-zen/</link>
		<comments>http://www.stoimen.com/blog/2010/03/17/javascript-zen/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 08:15:42 +0000</pubDate>
		<dc:creator>Stoimen</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[Bo]]></category>
		<category><![CDATA[Crockford]]></category>
		<category><![CDATA[Defined and undefined]]></category>

		<guid isPermaLink="false">http://www.stoimen.com/blog/?p=1338</guid>
		<description><![CDATA[Is undefined equal to undefined?
That&#8217;s the question! Crockford says it is not, but let see the experiment.

var a, b;
console.log&#40;typeof a&#41;;
console.log&#40;a === b&#41;;

the answer is &#8211; it is.



Related posts:javascript: what is typeof typeof
JavaScript closures in brief
jQuery localStorage plugin (alpha)



Related posts:<ol><li><a href='http://www.stoimen.com/blog/2009/07/27/javascript-what-is-typeof-typeof/' rel='bookmark' title='Permanent Link: javascript: what is typeof typeof'>javascript: what is typeof typeof</a></li>
<li><a href='http://www.stoimen.com/blog/2009/07/08/javascript-closures-in-brief/' rel='bookmark' title='Permanent Link: JavaScript closures in brief'>JavaScript closures in brief</a></li>
<li><a href='http://www.stoimen.com/blog/2010/02/26/jquery-localstorage-plugin-alpha/' rel='bookmark' title='Permanent Link: jQuery localStorage plugin (alpha)'>jQuery localStorage plugin (alpha)</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<h2>Is undefined equal to undefined?</h2>
<p>That&#8217;s the question! <a href="http://www.crockford.com/">Crockford</a> says it is not, but let see the experiment.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> a<span style="color: #339933;">,</span> b<span style="color: #339933;">;</span>
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> a<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>a <span style="color: #339933;">===</span> b<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>the answer is &#8211; it is.</p>
<p><a href="http://www.stoimen.com/blog/wp-content/uploads/2010/03/Picture-21.png"><img class="aligncenter size-full wp-image-1339" title="JavaScript zen" src="http://www.stoimen.com/blog/wp-content/uploads/2010/03/Picture-21.png" alt="" width="430" height="147" /></a></p>


<p>Related posts:<ol><li><a href='http://www.stoimen.com/blog/2009/07/27/javascript-what-is-typeof-typeof/' rel='bookmark' title='Permanent Link: javascript: what is typeof typeof'>javascript: what is typeof typeof</a></li>
<li><a href='http://www.stoimen.com/blog/2009/07/08/javascript-closures-in-brief/' rel='bookmark' title='Permanent Link: JavaScript closures in brief'>JavaScript closures in brief</a></li>
<li><a href='http://www.stoimen.com/blog/2010/02/26/jquery-localstorage-plugin-alpha/' rel='bookmark' title='Permanent Link: jQuery localStorage plugin (alpha)'>jQuery localStorage plugin (alpha)</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.stoimen.com/blog/2010/03/17/javascript-zen/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Retrieving YouTube Channel&#8217;s Videos with Zend_Gdata_YouTube</title>
		<link>http://www.stoimen.com/blog/2010/03/16/retrieving-youtube-channels-videos-with-zend_gdata_youtube/</link>
		<comments>http://www.stoimen.com/blog/2010/03/16/retrieving-youtube-channels-videos-with-zend_gdata_youtube/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 11:53:32 +0000</pubDate>
		<dc:creator>Stoimen</dc:creator>
				<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[zend framework]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Application programming interface]]></category>
		<category><![CDATA[Atom]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[GData]]></category>
		<category><![CDATA[Google Inc.]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[PHP programming language]]></category>
		<category><![CDATA[RSS]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[Web application frameworks]]></category>
		<category><![CDATA[World Wide Web]]></category>
		<category><![CDATA[YouTube Inc]]></category>

		<guid isPermaLink="false">http://www.stoimen.com/blog/?p=1329</guid>
		<description><![CDATA[Zend_Gdata
Zend Framework gives you the possibility to interact with Gdata services, which are provided by most of the Goolge services. You can find more on the docs page of Zend_Gdata. The basic principle is that you can connect a service with you API key, given by Google. What I&#8217;m about to show you is how [...]


Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/03/15/force-zend-casting-and-help-the-ide-autocompletion/' rel='bookmark' title='Permanent Link: Force Zend Casting and Help the IDE Autocompletion'>Force Zend Casting and Help the IDE Autocompletion</a></li>
<li><a href='http://www.stoimen.com/blog/2010/01/23/youtube-and-vimeo-goes-html5-with-video-tag-usage-catch-them-up/' rel='bookmark' title='Permanent Link: YouTube and Vimeo goes HTML5 with video tag usage! Catch them up!'>YouTube and Vimeo goes HTML5 with video tag usage! Catch them up!</a></li>
<li><a href='http://www.stoimen.com/blog/2010/01/29/cool-tutorial-about-zend_paginator/' rel='bookmark' title='Permanent Link: Cool tutorial about Zend_Paginator'>Cool tutorial about Zend_Paginator</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<h2>Zend_Gdata</h2>
<p><a title="Zend Framework" href="http://framework.zend.com/" target="_blank">Zend Framework</a> gives you the possibility to interact with <a title="gdata" href="http://code.google.com/apis/gdata/" target="_blank">Gdata</a> services, which are provided by most of the Goolge services. You can find more on the docs page of <a href="http://framework.zend.com/manual/en/zend.gdata.html" target="_blank">Zend_Gdata</a>. The basic principle is that you can connect a service with you API key, given by Google. What I&#8217;m about to show you is how do connect such a service.</p>
<p>In theory Zend_Gdata depends on <a title="Zend_Http_Client" href="http://framework.zend.com/manual/en/zend.http.html" target="_blank">Zend_Http_Client</a> and you&#8217;ve to connect it with an instance of this class.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// 1. setup API key</span>
<span style="color: #000088;">$apiKey</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'your_api_key_here'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// 2. retrieve videos via GData Atom</span>
<span style="color: #000088;">$client</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Http_Client<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$gdata</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Gdata_YouTube<span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'my-app'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #000088;">$apiKey</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Note that you&#8217;ve to replace your API key in the chunk above.</p>
<p>Now once that you&#8217;ve connected the YouTube service you can iterate through the entries from the video feed.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$videoFeed</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$gdata</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getUserUploads</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'username'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$videoFeed</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$entry</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$entry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getTitle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The thing is that you can modify a bit the code above. As ZF docs says if you don&#8217;t setup a Zend_Http_Client a default with default configuration, so you can omit this and simple write:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// 1. setup API key</span>
<span style="color: #000088;">$apiKey</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'your_api_key_here'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// 2. retrieve videos via GData Atom</span>
<span style="color: #000088;">$gdata</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Gdata_YouTube<span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'my-app'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #000088;">$apiKey</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>



<p>Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/03/15/force-zend-casting-and-help-the-ide-autocompletion/' rel='bookmark' title='Permanent Link: Force Zend Casting and Help the IDE Autocompletion'>Force Zend Casting and Help the IDE Autocompletion</a></li>
<li><a href='http://www.stoimen.com/blog/2010/01/23/youtube-and-vimeo-goes-html5-with-video-tag-usage-catch-them-up/' rel='bookmark' title='Permanent Link: YouTube and Vimeo goes HTML5 with video tag usage! Catch them up!'>YouTube and Vimeo goes HTML5 with video tag usage! Catch them up!</a></li>
<li><a href='http://www.stoimen.com/blog/2010/01/29/cool-tutorial-about-zend_paginator/' rel='bookmark' title='Permanent Link: Cool tutorial about Zend_Paginator'>Cool tutorial about Zend_Paginator</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.stoimen.com/blog/2010/03/16/retrieving-youtube-channels-videos-with-zend_gdata_youtube/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Force Zend Casting and Help the IDE Autocompletion</title>
		<link>http://www.stoimen.com/blog/2010/03/15/force-zend-casting-and-help-the-ide-autocompletion/</link>
		<comments>http://www.stoimen.com/blog/2010/03/15/force-zend-casting-and-help-the-ide-autocompletion/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 14:28:02 +0000</pubDate>
		<dc:creator>Stoimen</dc:creator>
				<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[zend framework]]></category>
		<category><![CDATA[Autocomplete]]></category>
		<category><![CDATA[YouTube]]></category>
		<category><![CDATA[Zend_Gdata_YouTube_VideoEntry]]></category>

		<guid isPermaLink="false">http://www.stoimen.com/blog/?p=1320</guid>
		<description><![CDATA[IDEs and Autocompletion
One of my favorite things in IDEs, in my case Eclipse for Mac, is that they offer you the option of autocompletion. No developer knows the entire set of functions of the language he uses, neither the set of parameters of them. That&#8217;s why IDEs come to help.

In many cases when casting is [...]


Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/03/16/retrieving-youtube-channels-videos-with-zend_gdata_youtube/' rel='bookmark' title='Permanent Link: Retrieving YouTube Channel&#8217;s Videos with Zend_Gdata_YouTube'>Retrieving YouTube Channel&#8217;s Videos with Zend_Gdata_YouTube</a></li>
<li><a href='http://www.stoimen.com/blog/2010/02/02/firebugs-console-time-accuracy/' rel='bookmark' title='Permanent Link: Firebug&#8217;s console.time() accuracy'>Firebug&#8217;s console.time() accuracy</a></li>
<li><a href='http://www.stoimen.com/blog/2009/04/21/zend-framework-disable-zend-layout/' rel='bookmark' title='Permanent Link: Zend Framework &#8211; Disable Zend Layout'>Zend Framework &#8211; Disable Zend Layout</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<h2>IDEs and Autocompletion</h2>
<p>One of my favorite things in IDEs, in my case Eclipse for Mac, is that they offer you the option of autocompletion. No developer knows the entire set of functions of the language he uses, neither the set of parameters of them. That&#8217;s why IDEs come to help.</p>
<p style="text-align: center;"><a href="http://www.stoimen.com/blog/wp-content/uploads/2010/03/Eclipse.Autocompletion.png"><img class="aligncenter size-full wp-image-1325" title="Eclipse Autocompletion" src="http://www.stoimen.com/blog/wp-content/uploads/2010/03/Eclipse.Autocompletion.png" alt="" width="430" height="185" /></a></p>
<p>In many cases when casting is not obvious and method call chain is to large your IDE may refuse to help you with this brilliant functionality. To be more precise let me give you an example.</p>
<p>In Zend Framework I was trying to fetch a RSS via Gdata interface. Something like that:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$videoFeed</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$gdata</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getUserUploads</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'youtube_username'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$videoFeed</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$entry</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// do something</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The problem is that whenever I try to do <strong>$entry-&gt;</strong> in the body of the <strong>foreach</strong> loop I don&#8217;t see what methods are supported by the <strong>Zend_Gdata_YouTube_VideoEntry</strong> class. So I tried to force the casting of $entry to this class definition and it worked like a charm for me. The thing I&#8217;ve done was to add a definition of $entry before the loop body:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$videoFeed</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$gdata</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getUserUploads</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'youtube_username'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$entry</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Gdata_YouTube_VideoEntry<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span>  <span style="color: #009900;">&#40;</span><span style="color: #000088;">$videoFeed</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$entry</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// do something</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Than whenever you try to type $entry-&gt; you&#8217;d receive a list of methods from the class definition of <strong>Zend_Gdata_YouTube_VideoEntry</strong>.</p>
<p>Thanks to <a href="http://ganoro.blogspot.com/">Roy Ganor</a> there&#8217;s a more elegant way to do this, simply by adding @var comment:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/* @var $entry Zend_Gdata_YouTube_VideoEntry */</span></pre></div></div>



<p>Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/03/16/retrieving-youtube-channels-videos-with-zend_gdata_youtube/' rel='bookmark' title='Permanent Link: Retrieving YouTube Channel&#8217;s Videos with Zend_Gdata_YouTube'>Retrieving YouTube Channel&#8217;s Videos with Zend_Gdata_YouTube</a></li>
<li><a href='http://www.stoimen.com/blog/2010/02/02/firebugs-console-time-accuracy/' rel='bookmark' title='Permanent Link: Firebug&#8217;s console.time() accuracy'>Firebug&#8217;s console.time() accuracy</a></li>
<li><a href='http://www.stoimen.com/blog/2009/04/21/zend-framework-disable-zend-layout/' rel='bookmark' title='Permanent Link: Zend Framework &#8211; Disable Zend Layout'>Zend Framework &#8211; Disable Zend Layout</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.stoimen.com/blog/2010/03/15/force-zend-casting-and-help-the-ide-autocompletion/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>JavaScript Snippets: IF Statements Optimization Part 2</title>
		<link>http://www.stoimen.com/blog/2010/03/14/javascript-snippets-if-statements-optimization-part-2/</link>
		<comments>http://www.stoimen.com/blog/2010/03/14/javascript-snippets-if-statements-optimization-part-2/#comments</comments>
		<pubDate>Sun, 14 Mar 2010 18:39:08 +0000</pubDate>
		<dc:creator>Stoimen</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[Coding theory]]></category>
		<category><![CDATA[Computer errors]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Error]]></category>
		<category><![CDATA[Error detection and correction]]></category>
		<category><![CDATA[Error message]]></category>
		<category><![CDATA[Knowledge]]></category>
		<category><![CDATA[Social psychology]]></category>

		<guid isPermaLink="false">http://www.stoimen.com/blog/?p=1312</guid>
		<description><![CDATA[What if &#8230;
continuing from the previous post let assume there&#8217;s the following code:

if &#40; thisIsTrue &#41; &#123;
   if &#40; myFuncReturnsTrue&#40;&#41; &#41; &#123;
      printMe&#40;'success'&#41;;
   &#125; else &#123;
      printMe&#40;'error'&#41;;
   &#125;
&#125;

This can be easily ported to:

thisIsTrue &#38;&#38; &#40;myFuncReturnsTrue&#40;&#41; ? printMe&#40;'success'&#41; : printMe&#40;'error'&#41;&#41;;

Source
You [...]


Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/03/14/javascript-snippets-if-statements-optimization/' rel='bookmark' title='Permanent Link: JavaScript Snippets: IF Statements Optimization'>JavaScript Snippets: IF Statements Optimization</a></li>
<li><a href='http://www.stoimen.com/blog/2010/02/07/javascript-optimization-optimizing-if-statements/' rel='bookmark' title='Permanent Link: JavaScript optimization. Optimizing IF statements.'>JavaScript optimization. Optimizing IF statements.</a></li>
<li><a href='http://www.stoimen.com/blog/2010/03/21/javascript-comparision-snippet/' rel='bookmark' title='Permanent Link: JavaScript Comparision Snippet'>JavaScript Comparision Snippet</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<h2>What if &#8230;</h2>
<p>continuing from the previous post let assume there&#8217;s the following code:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> thisIsTrue <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> myFuncReturnsTrue<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      printMe<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'success'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
      printMe<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'error'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This can be easily ported to:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">thisIsTrue <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span>myFuncReturnsTrue<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> printMe<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'success'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> printMe<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'error'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h2>Source</h2>
<p>You can see the demo source <a title="JavaScript Conditional Optimization" href="http://www.stoimen.com/projects/javascript.conditional.optimization/" target="_blank">here</a>. Here&#8217;s a snippet:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> func1<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'func1'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">function</span> func2<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'func2'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> a <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> b <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
a <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span>b <span style="color: #339933;">?</span> func1<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> func2<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>



<p>Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/03/14/javascript-snippets-if-statements-optimization/' rel='bookmark' title='Permanent Link: JavaScript Snippets: IF Statements Optimization'>JavaScript Snippets: IF Statements Optimization</a></li>
<li><a href='http://www.stoimen.com/blog/2010/02/07/javascript-optimization-optimizing-if-statements/' rel='bookmark' title='Permanent Link: JavaScript optimization. Optimizing IF statements.'>JavaScript optimization. Optimizing IF statements.</a></li>
<li><a href='http://www.stoimen.com/blog/2010/03/21/javascript-comparision-snippet/' rel='bookmark' title='Permanent Link: JavaScript Comparision Snippet'>JavaScript Comparision Snippet</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.stoimen.com/blog/2010/03/14/javascript-snippets-if-statements-optimization-part-2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>JavaScript Snippets: IF Statements Optimization</title>
		<link>http://www.stoimen.com/blog/2010/03/14/javascript-snippets-if-statements-optimization/</link>
		<comments>http://www.stoimen.com/blog/2010/03/14/javascript-snippets-if-statements-optimization/#comments</comments>
		<pubDate>Sun, 14 Mar 2010 18:28:46 +0000</pubDate>
		<dc:creator>Stoimen</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[Computer programming]]></category>
		<category><![CDATA[Computer science]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Curly bracket programming languages]]></category>
		<category><![CDATA[JavaScript programming language]]></category>
		<category><![CDATA[JavaScript syntax]]></category>
		<category><![CDATA[Scripting languages]]></category>
		<category><![CDATA[Technology/Internet]]></category>

		<guid isPermaLink="false">http://www.stoimen.com/blog/?p=1307</guid>
		<description><![CDATA[A &#8220;Typical Installation&#8221; &#8230;
As most of the desktop software gives us opportunity to choose from typical or custom installations, let me write what&#8217;s a typical IF conditional statement in JavaScript and &#8230; every other programing language.

if &#40; thisIsTrue &#41; &#123;
    printMe&#40;&#34;some message&#34;&#41;;
&#125;

A &#8220;Custom Installation&#8221; &#8230;
The first thing you can improve from the [...]


Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/03/14/javascript-snippets-if-statements-optimization-part-2/' rel='bookmark' title='Permanent Link: JavaScript Snippets: IF Statements Optimization Part 2'>JavaScript Snippets: IF Statements Optimization Part 2</a></li>
<li><a href='http://www.stoimen.com/blog/2010/02/07/javascript-optimization-optimizing-if-statements/' rel='bookmark' title='Permanent Link: JavaScript optimization. Optimizing IF statements.'>JavaScript optimization. Optimizing IF statements.</a></li>
<li><a href='http://www.stoimen.com/blog/2010/03/10/php-if-else-endif-statements/' rel='bookmark' title='Permanent Link: PHP if-else-endif Statements'>PHP if-else-endif Statements</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<h2>A &#8220;Typical Installation&#8221; &#8230;</h2>
<p>As most of the desktop software gives us opportunity to choose from typical or custom installations, let me write what&#8217;s a typical IF conditional statement in JavaScript and &#8230; every other programing language.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> thisIsTrue <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    printMe<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;some message&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h2>A &#8220;Custom Installation&#8221; &#8230;</h2>
<p>The first thing you can improve from the code above is removing the brackets.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> thisIsTrue <span style="color: #009900;">&#41;</span>
    printMe<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;someMessage&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Because in JavaScript everything&#8217;s on the client &#8211; every symbol matters. What if we remove as much as we can!</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">thisIsTrue <span style="color: #339933;">&amp;&amp;</span> printMe<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;someMessage&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>



<p>Related posts:<ol><li><a href='http://www.stoimen.com/blog/2010/03/14/javascript-snippets-if-statements-optimization-part-2/' rel='bookmark' title='Permanent Link: JavaScript Snippets: IF Statements Optimization Part 2'>JavaScript Snippets: IF Statements Optimization Part 2</a></li>
<li><a href='http://www.stoimen.com/blog/2010/02/07/javascript-optimization-optimizing-if-statements/' rel='bookmark' title='Permanent Link: JavaScript optimization. Optimizing IF statements.'>JavaScript optimization. Optimizing IF statements.</a></li>
<li><a href='http://www.stoimen.com/blog/2010/03/10/php-if-else-endif-statements/' rel='bookmark' title='Permanent Link: PHP if-else-endif Statements'>PHP if-else-endif Statements</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.stoimen.com/blog/2010/03/14/javascript-snippets-if-statements-optimization/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
