<?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>web developer &#8211; stoimen&#039;s web log</title>
	<atom:link href="/tag/web-developer/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>Should I do Something Only Because Crockford Says So?</title>
		<link>/2010/04/09/should-i-do-something-only-because-crockford-says-so/</link>
		<comments>/2010/04/09/should-i-do-something-only-because-crockford-says-so/#respond</comments>
		<pubDate>Fri, 09 Apr 2010 14:43:23 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[Computer programming]]></category>
		<category><![CDATA[Computer science]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Crockford]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[JavaScript programming language]]></category>
		<category><![CDATA[Scripting languages]]></category>
		<category><![CDATA[web developer]]></category>

		<guid isPermaLink="false">/?p=1427</guid>
		<description><![CDATA[Crockford says: &#8220;Don&#8217;t do that, please stop doing it!?&#8221; It may be related to JavaScript, YUI, CSS or whatever. PPK recently posted about browser prefixes with the same intonation. OK, fine, it&#8217;s difficult to maintain, it&#8217;s ugly but my job is to make the site look as nice as possible. I agree with Crokford that &#8230; <a href="/2010/04/09/should-i-do-something-only-because-crockford-says-so/" class="more-link">Continue reading <span class="screen-reader-text">Should I do Something Only Because Crockford Says So?</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2009/03/14/javascript-code-convention/" rel="bookmark" title="JavaScript code convention">JavaScript code convention </a></li>
<li><a href="/2010/05/24/javascript-objects-coding-style/" rel="bookmark" title="JavaScript Objects Coding Style">JavaScript Objects Coding Style </a></li>
<li><a href="/2010/06/11/friday-algorithms-quicksort-difference-between-php-and-javascript/" rel="bookmark" title="Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript">Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript </a></li>
<li><a href="/2010/06/24/zend-framework-inject-javascript-code-in-a-actionview/" rel="bookmark" title="Zend Framework: Inject JavaScript Code in a Action/View">Zend Framework: Inject JavaScript Code in a Action/View </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p><a title="Crockford" href="http://www.crockford.com/" target="_blank">Crockford</a> says: &#8220;Don&#8217;t do that, please stop doing it!?&#8221; It may be related to JavaScript, YUI, CSS or whatever. <a title="PPK" href="http://www.quirksmode.org/" target="_blank">PPK</a> recently posted about browser prefixes with the same intonation. OK, fine, it&#8217;s difficult to maintain, it&#8217;s ugly but my job is to make the site look as nice as possible.</p>
<p>I agree with Crokford that only with copy/paste now JavaScript has the reputation of badly standardized language with no programmers that understand it at all. It&#8217;s true, but however this maybe made JavaScript so popular, now all the libraries come with that abstraction in mind and this gap seems to be smaller.</p>
<p>In addition I&#8217;ll say that&#8217;s fine if Crockford or PPK say something like that, but the primary goal of every web developer is not to be in good relations with Crockford, but to satisfy clients! I&#8217;d like to repeat &#8211; clients!</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2009/03/14/javascript-code-convention/" rel="bookmark" title="JavaScript code convention">JavaScript code convention </a></li>
<li><a href="/2010/05/24/javascript-objects-coding-style/" rel="bookmark" title="JavaScript Objects Coding Style">JavaScript Objects Coding Style </a></li>
<li><a href="/2010/06/11/friday-algorithms-quicksort-difference-between-php-and-javascript/" rel="bookmark" title="Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript">Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript </a></li>
<li><a href="/2010/06/24/zend-framework-inject-javascript-code-in-a-actionview/" rel="bookmark" title="Zend Framework: Inject JavaScript Code in a Action/View">Zend Framework: Inject JavaScript Code in a Action/View </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/04/09/should-i-do-something-only-because-crockford-says-so/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS border-radius vs. images!</title>
		<link>/2010/02/12/css-border-radius-vs-images/</link>
		<comments>/2010/02/12/css-border-radius-vs-images/#respond</comments>
		<pubDate>Fri, 12 Feb 2010 09:24:22 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[Cascading Style Sheets]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[Microsoft Corporation]]></category>
		<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[Tableless web design]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[Web design]]></category>
		<category><![CDATA[web designers]]></category>
		<category><![CDATA[web developer]]></category>
		<category><![CDATA[WebKit]]></category>
		<category><![CDATA[World Wide Web]]></category>

		<guid isPermaLink="false">/?p=1082</guid>
		<description><![CDATA[Rounded corners This is one of the main problems of web design and development now, even if it sounds strange. The thing is that with round corners the elements become more nice and groovy and most of the web designers make such design templates. The problem than comes over the web developer who&#8217;s supposed to &#8230; <a href="/2010/02/12/css-border-radius-vs-images/" class="more-link">Continue reading <span class="screen-reader-text">CSS border-radius vs. images!</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/03/27/vendor-prefixes-in-css/" rel="bookmark" title="Vendor Prefixes in CSS">Vendor Prefixes in CSS </a></li>
<li><a href="/2010/02/17/htc-round-the-corners-on-ie/" rel="bookmark" title="HTC?! Round the corners on IE!">HTC?! Round the corners on IE! </a></li>
<li><a href="/2010/02/05/css-sprites-go-beyond-the-limits-with-base64/" rel="bookmark" title="CSS sprites. Go beyond the limits with base64!">CSS sprites. Go beyond the limits with base64! </a></li>
<li><a href="/2010/02/15/cross-browser-rounded-corners-works-on-ie-but-but-not-on-opera/" rel="bookmark" title="Cross-browser rounded corners! Works on IE but, but not on Opera!">Cross-browser rounded corners! Works on IE but, but not on Opera! </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>Rounded corners</h2>
<p>This is one of the main problems of web design and development now, even if it sounds strange. The thing is that with round corners the elements become more nice and groovy and most of the web designers make such design templates. The problem than comes over the web developer who&#8217;s supposed to convert this into HTML and CSS. Of course it would be nice if all browsers support rounded corners in CSS, but they don&#8217;t and guess what IE fully doesn&#8217;t support it.</p>
<blockquote>
<pre>-moz and -webkit</pre>
</blockquote>
<p>Most of you have heart about this patches in CSS when you can use this prefixes for Mozilla based and Safari&#8217;s Webkit based browsers. Than you can use border radius with no pain, and you get the same effect as with using images.</p>
<blockquote>
<pre>-moz-border-radius : 4px;
-webkit-border-radius : 4px;
</pre>
</blockquote>
<p>Of course on IE this doesn&#8217;t work and the element remains with square corners. But what the question is, should we make both versions for non IE browsers without images and a version for the &#8220;great&#8221; MSIE and all of its versions?</p>
<h2>My answer is: no!</h2>
<p>Although many sites do that, see vimeo for instance, there&#8217;s no need to support that. As the rumor and the MSIE blog says in IE9 which is &#8230; coming soon there will be &#8211; <strong>border-radius</strong> property.</p>
<h2>That&#8217;s awesome!</h2>
<p>Finally Microsoft has done something good! So stop using background images! This is hard to maintain, difficult to make and it&#8217;s bad for the browser loading time, because of the extra images/sprites.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/03/27/vendor-prefixes-in-css/" rel="bookmark" title="Vendor Prefixes in CSS">Vendor Prefixes in CSS </a></li>
<li><a href="/2010/02/17/htc-round-the-corners-on-ie/" rel="bookmark" title="HTC?! Round the corners on IE!">HTC?! Round the corners on IE! </a></li>
<li><a href="/2010/02/05/css-sprites-go-beyond-the-limits-with-base64/" rel="bookmark" title="CSS sprites. Go beyond the limits with base64!">CSS sprites. Go beyond the limits with base64! </a></li>
<li><a href="/2010/02/15/cross-browser-rounded-corners-works-on-ie-but-but-not-on-opera/" rel="bookmark" title="Cross-browser rounded corners! Works on IE but, but not on Opera!">Cross-browser rounded corners! Works on IE but, but not on Opera! </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/02/12/css-border-radius-vs-images/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fancy tooltips with jQuery</title>
		<link>/2010/02/06/fancy-tooltips-with-jquery/</link>
		<comments>/2010/02/06/fancy-tooltips-with-jquery/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 07:25:19 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[Fancy]]></category>
		<category><![CDATA[Graphical user interface]]></category>
		<category><![CDATA[Human Interest]]></category>
		<category><![CDATA[Sampling]]></category>
		<category><![CDATA[Tooltip]]></category>
		<category><![CDATA[User interface techniques]]></category>
		<category><![CDATA[web developer]]></category>
		<category><![CDATA[Widgets]]></category>

		<guid isPermaLink="false">/?p=638</guid>
		<description><![CDATA[I was decided to write this post from long time ago and now I&#8217;m pretty sure it has to be published. What I see in my practice and my browsing in the web there are too many old fashioned tooltips all over the web, as web developer don&#8217;t know how to make pretty good fancy &#8230; <a href="/2010/02/06/fancy-tooltips-with-jquery/" class="more-link">Continue reading <span class="screen-reader-text">Fancy tooltips with jQuery</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/02/16/jquery-tooltip-plugin/" rel="bookmark" title="jQuery tooltip plugin!">jQuery tooltip plugin! </a></li>
<li><a href="/2010/02/17/clickoutside-jquery-plugin/" rel="bookmark" title="clickoutside jQuery plugin">clickoutside jQuery plugin </a></li>
<li><a href="/2009/10/21/event-driven-programming-with-jquery-part-2-events-in-jquery/" rel="bookmark" title="Event driven programming with jQuery &#8211; (part 2). Events in jQuery.">Event driven programming with jQuery &#8211; (part 2). Events in jQuery. </a></li>
<li><a href="/2010/02/02/firebugs-console-time-accuracy/" rel="bookmark" title="Firebug&#8217;s console.time() accuracy">Firebug&#8217;s console.time() accuracy </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>I was decided to write this post from long time ago and now I&#8217;m pretty sure it has to be published. What I see in my practice and my browsing in the web there are too many old fashioned tooltips all over the web, as web developer don&#8217;t know how to make pretty good fancy tooltips.</p>
<p>That&#8217;s why I decided to show what&#8217;s not and what is fancy tooltip, with the help of jQuery. Of course don&#8217;t hesitate to make with every other library or pure JS code.</p>
<h2>What is NOT fancy?</h2>
<p>It&#8217;s not fancy when the tooltip is with fixed position. In the example <a href="http://www.stoimen.com/jquery.fancy.tooltip.plugin/not-fancy.html" target="_blank">here</a> I made one pretty small sample:</p>
<p><a href="/wp-content/uploads/2010/02/not-fancy.png"><img class="aligncenter size-full wp-image-1066" title="not-fancy" src="/wp-content/uploads/2010/02/not-fancy.png" alt="" width="288" height="183" /></a></p>
<h2>What is fancy?</h2>
<p>In the other side you can make the tooltip moving with the mouse pointer which is way better, as you can see <a href="http://www.stoimen.com/jquery.fancy.tooltip.plugin/fancy.html" target="_blank">here</a>:</p>
<p><a href="/wp-content/uploads/2010/02/fancy.png"><img class="aligncenter size-full wp-image-1065" title="fancy" src="/wp-content/uploads/2010/02/fancy.png" alt="" width="300" height="165" /></a></p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/02/16/jquery-tooltip-plugin/" rel="bookmark" title="jQuery tooltip plugin!">jQuery tooltip plugin! </a></li>
<li><a href="/2010/02/17/clickoutside-jquery-plugin/" rel="bookmark" title="clickoutside jQuery plugin">clickoutside jQuery plugin </a></li>
<li><a href="/2009/10/21/event-driven-programming-with-jquery-part-2-events-in-jquery/" rel="bookmark" title="Event driven programming with jQuery &#8211; (part 2). Events in jQuery.">Event driven programming with jQuery &#8211; (part 2). Events in jQuery. </a></li>
<li><a href="/2010/02/02/firebugs-console-time-accuracy/" rel="bookmark" title="Firebug&#8217;s console.time() accuracy">Firebug&#8217;s console.time() accuracy </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/02/06/fancy-tooltips-with-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Speed up the JavaScript. It can change dramatically the user experience.</title>
		<link>/2010/01/31/speed-up-the-javascript-it-can-change-dramatically-the-user-experience/</link>
		<comments>/2010/01/31/speed-up-the-javascript-it-can-change-dramatically-the-user-experience/#respond</comments>
		<pubDate>Sun, 31 Jan 2010 07:06:52 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[Computer science]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Google Inc.]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[JavaScript library]]></category>
		<category><![CDATA[JavaScript programming language]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[Minification]]></category>
		<category><![CDATA[Software engineering]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[The Times Global Broadcasting Co Ltd]]></category>
		<category><![CDATA[Twitter Inc]]></category>
		<category><![CDATA[Web application]]></category>
		<category><![CDATA[web apps]]></category>
		<category><![CDATA[web developer]]></category>
		<category><![CDATA[Yahoo! Inc.]]></category>
		<category><![CDATA[YouTube Inc]]></category>

		<guid isPermaLink="false">/?p=874</guid>
		<description><![CDATA[JavaScript in a modern web application If someone asks you what is the javascript in modern web developer, probably you should answer it’s almost the half of the traffic of your site and it’s almost everything when dealing with user experience. Today’s big web apps are useless without it AJAX/JS part. Think about Facebook, Google &#8230; <a href="/2010/01/31/speed-up-the-javascript-it-can-change-dramatically-the-user-experience/" class="more-link">Continue reading <span class="screen-reader-text">Speed up the JavaScript. It can change dramatically the user experience.</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/02/11/javascript-optimization-lazy-loading/" rel="bookmark" title="JavaScript optimization. Lazy loading.">JavaScript optimization. Lazy loading. </a></li>
<li><a href="/2010/03/12/javascript-libraries-popularity/" rel="bookmark" title="Javascript Libraries Popularity">Javascript Libraries Popularity </a></li>
<li><a href="/2010/06/29/html5-geolocation-what-if-the-user-doesnt-share-his-position/" rel="bookmark" title="HTML5 geolocation &#8211; What If the User Doesn&#8217;t Share His Position?">HTML5 geolocation &#8211; What If the User Doesn&#8217;t Share His Position? </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>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>JavaScript in a modern web application</h2>
<p>If someone asks you what is the javascript in modern web developer, probably you should answer it’s almost the half of the traffic of your site and it’s almost everything when dealing with user experience.</p>
<p>Today’s big web apps are useless without it AJAX/JS part. Think about <a title="facebook" href="http://facebook.com/" target="_blank">Facebook</a>, <a title="google products" href="http://google.com/" target="_blank">Google products</a>, <a title="twitter" href="http://twitter.com/" target="_blank">Twitter</a>, <a title="yahoo" href="http://yahoo.com/" target="_blank">Yahoo!</a>, <a title="youtube" href="http://youtube.com/" target="_blank">Youtube</a>.</p>
<p>Actually they made this a standart. The times when you used to use JavaScript as a helper language just to figure out how a drop down menu will work are far way in the past. Now JavaScript is everything in a rich web sites. With no JS they will be no rich at all! Then it comes the question how to improve sites with lots of javascript. Actually one of the main problems in the web now is that JavaScript is blocking content.</p>
<h2>Blocked by the JavaScript</h2>
<p>What that means at all is that until the browser receives and parses the JavaScript file/s it doesn’t process anything else, it even doesn’t load any other resources. Now you can imagine how big the problem is. When it comes to large files more than 100K the user experience will be very bad!</p>
<h2>Optimize the web? What about optimizing JavaScript!</h2>
<p>If the problem is so big as I described above why should we doubt about where to start with the optimization process? But of course with the JavaScript and the natural question that rises is how this can be optimized at all?</p>
<h2>Three steps</h2>
<p>Like me, many of you may heart of some techniques that improve javascript performance. Here are some I was able to select as important:</p>
<h3>1. minify/compress</h3>
<blockquote><p>That’s rule number one. If everything that is a JavaScript file is processed once it arrives to the client than make it smaller and make it go faster trough the wire. Actually one technique to speed up things more is to concatenated all the files you have into one single big file. Although this will not spend you some space will reduce the HTTP requests and therefore speed up the loading process.  Good tools that you can use to minify javascript files are the Yahoo’s YUI Compressor, that beside that compresses CSS and Google Closure Compiler. Both are extremely useful and by the last measurements the Google’s Compiler is even better, but it’s up to you to decide which one to pick up.</p></blockquote>
<h3>2 .write fast and smart code</h3>
<blockquote><p>You can minify everything that’s JavaScript and the code may remain slow. But why is that? That’s because the JavaScript is written in a bad way. You know there are many resources in the web describing what is a bad and what is a good practice when writing JS. Even more you can measure it by yourself if you’d like to use the Firebug’s profiler. That’s a good start to avoid bad practices.</p></blockquote>
<h3>3. improve loading &#8211; lazy loading</h3>
<blockquote><p>That’s a bit more complicated. If there’s a really big javascript file after compressing and concatenating all the JS functionality remains big. How to avoid that? Simply let’s the user to see the most important functionality and than load the entire app. Some good tutorials about lazy loading again can be found online. Don’t hesitate to search about.</p></blockquote>
<p>Beside this really basic advices I’ll continue to write in my blog about specific techniques how to improve the JavaScript as this is one of the most interesting parts of web development by me.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/02/11/javascript-optimization-lazy-loading/" rel="bookmark" title="JavaScript optimization. Lazy loading.">JavaScript optimization. Lazy loading. </a></li>
<li><a href="/2010/03/12/javascript-libraries-popularity/" rel="bookmark" title="Javascript Libraries Popularity">Javascript Libraries Popularity </a></li>
<li><a href="/2010/06/29/html5-geolocation-what-if-the-user-doesnt-share-his-position/" rel="bookmark" title="HTML5 geolocation &#8211; What If the User Doesn&#8217;t Share His Position?">HTML5 geolocation &#8211; What If the User Doesn&#8217;t Share His Position? </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>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/01/31/speed-up-the-javascript-it-can-change-dramatically-the-user-experience/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>cssText and how it can be very very useful</title>
		<link>/2009/12/23/csstext-and-how-it-can-be-very-very-useful/</link>
		<comments>/2009/12/23/csstext-and-how-it-can-be-very-very-useful/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 14:34:41 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[JavaScript programming language]]></category>
		<category><![CDATA[web developer]]></category>
		<category><![CDATA[web development sky]]></category>

		<guid isPermaLink="false">/?p=834</guid>
		<description><![CDATA[We all know, or at least all of us reading every new coming news on the web development sky, that making your browser reflow and repaint is expensive. Actually it is quite expensive. What I&#8217;m about to say comes under the tag of &#8220;very good news&#8221; for those how didn&#8217;t know what repaint as and &#8230; <a href="/2009/12/23/csstext-and-how-it-can-be-very-very-useful/" class="more-link">Continue reading <span class="screen-reader-text">cssText and how it can be very very useful</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/03/17/jquery-csstext-helps-you-improve-browser-reflows/" rel="bookmark" title="jQuery cssText Helps You Improve Browser Reflows">jQuery cssText Helps You Improve Browser Reflows </a></li>
<li><a href="/2009/11/04/jquery-css-selectors-change-one-or-more-css-properties/" rel="bookmark" title="jQuery CSS selectors. Change one or more CSS properties!">jQuery CSS selectors. Change one or more CSS properties! </a></li>
<li><a href="/2011/03/29/scroll-an-iframe-content-to-a-predefined-position/" rel="bookmark" title="Scroll an IFRAME Content to a Predefined Position">Scroll an IFRAME Content to a Predefined Position </a></li>
<li><a href="/2009/11/30/toggle-the-visibility-with-jquery/" rel="bookmark" title="Toggle the visibility with jQuery">Toggle the visibility with jQuery </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>We all know, or at least all of us reading every new coming news on the web development sky, that making your browser reflow and repaint is expensive. Actually it is quite expensive.</p>
<p>What I&#8217;m about to say comes under the tag of &#8220;very good news&#8221; for those how didn&#8217;t know what repaint as and what cssText is.</p>
<p>When it comes to the repaint and reflow, which sounds really strange, there are lots and lots of articles what this is, but in breve, just to let you know what is and where&#8217;s the bad part of it I&#8217;ll describe it again.<span id="more-834"></span></p>
<p>Almost every web developer with little or more experience with JavaScript has accessed an element style property with it. This is done like so:</p>
<blockquote>
<pre>document.getElementById('element_id').style</pre>
</blockquote>
<p>Now when you try to dynamically place this object somewhere in the browser, you normally just write:</p>
<blockquote>
<pre>document.getElementById('element_id').style.top = '100px';
document.getElementById('element_id').style.left = '100px';
</pre>
</blockquote>
<p>and that&#8217;s when you assume the element is correctly built and his position is absolute. If not &#8211; even worse you&#8217;ve to make it, again with JavaScript. Which is so sad.</p>
<p>But where is the bad thing that happen in the code above? The bad thing is that the browser should now repaint what you see, once to show you the element with different top position, and again for the left position. This, of course, for the normal browsers occurs very quickly, but don&#8217;t ask what price your CPU pays for that!</p>
<p>In the case with only one element moved only once, that&#8217;s OK, but what if we move thousands of markers around a map every ten seconds? Than you cannot move your mouse because of the CPU usage.</p>
<p>The simple solution, which in fact is very &#8220;software&#8221; clear, is to make one class in the CSS definition with both top and left positions predefined:</p>
<blockquote>
<pre>.my-class { top: 100px; left : 100px;}</pre>
</blockquote>
<p>and to assign it with:</p>
<blockquote>
<pre>document.getElementById('element_id').setAttribute('className', 'my-class');</pre>
</blockquote>
<p>That code makes the browser to reflow only once.</p>
<p>But to make the things clear, let&#8217;s ask what if this top and left positions are dynamically calculated? You cannot predefined thousands of thousands of classes, don&#8217;t you? And if you can where the hell the optimization is gone?</p>
<p>The right answer is: use <strong>cssText</strong>.</p>
<p>This is the solution for large scale apps. Just replace the above code with:</p>
<blockquote>
<pre>document.getElementById('element_id').style.cssText += 'top:100px;left:100px;';</pre>
</blockquote>
<p>That helps the browser reflow only once and your CPU to breath. Even better that helps other people CPUs to breath, because as you know JavaScript code is executed on the client!</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/03/17/jquery-csstext-helps-you-improve-browser-reflows/" rel="bookmark" title="jQuery cssText Helps You Improve Browser Reflows">jQuery cssText Helps You Improve Browser Reflows </a></li>
<li><a href="/2009/11/04/jquery-css-selectors-change-one-or-more-css-properties/" rel="bookmark" title="jQuery CSS selectors. Change one or more CSS properties!">jQuery CSS selectors. Change one or more CSS properties! </a></li>
<li><a href="/2011/03/29/scroll-an-iframe-content-to-a-predefined-position/" rel="bookmark" title="Scroll an IFRAME Content to a Predefined Position">Scroll an IFRAME Content to a Predefined Position </a></li>
<li><a href="/2009/11/30/toggle-the-visibility-with-jquery/" rel="bookmark" title="Toggle the visibility with jQuery">Toggle the visibility with jQuery </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2009/12/23/csstext-and-how-it-can-be-very-very-useful/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
