<?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>jQuery Tutorials &#38; Plugins &#187; Selector</title>
	<atom:link href="http://jqueryblog.net/tag/selector/feed/" rel="self" type="application/rss+xml" />
	<link>http://jqueryblog.net</link>
	<description></description>
	<lastBuildDate>Mon, 05 Jul 2010 08:45:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>jQuery Optimization : Avoid Unnecessary Selector</title>
		<link>http://jqueryblog.net/2009/11/jquery-optimization-avoid-unnecessary-selector/</link>
		<comments>http://jqueryblog.net/2009/11/jquery-optimization-avoid-unnecessary-selector/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 15:38:35 +0000</pubDate>
		<dc:creator>Osman Erdo&#287;an</dc:creator>
				<category><![CDATA[jQuery Optimization]]></category>
		<category><![CDATA[Optimization]]></category>
		<category><![CDATA[Selector]]></category>
		<category><![CDATA[subexpression]]></category>
		<category><![CDATA[Unnecessary Selector]]></category>

		<guid isPermaLink="false">http://jqueryblog.net/?p=29</guid>
		<description><![CDATA[Common subexpression elimination is a common way to optimize any programming code. Doing unnecessary selector is expensive. Doing something like this:
jQuery('.class').each(function(){
	jQuery(this).html();
	jQuery(this).find('div').each(function(){
		//etc.
	});
});
which required many selector it is best to use 1 instead since we are repeating ourselves and doing some redundant selector.
jQuery('.class').each(function(){
	var obj = jQuery(this);
	obj.html();
	obj.find('div').each(function(){
		//etc.
	});
});
This is something that we often see in many plugin. Many plugin [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjqueryblog.net%2F2009%2F11%2Fjquery-optimization-avoid-unnecessary-selector%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjqueryblog.net%2F2009%2F11%2Fjquery-optimization-avoid-unnecessary-selector%2F" height="61" width="51" /></a></div><p>Common subexpression elimination is a common way to optimize any programming code. Doing unnecessary selector is expensive. Doing something like this:</p>
<pre class="brush: jscript;">jQuery('.class').each(function(){
	jQuery(this).html();
	jQuery(this).find('div').each(function(){
		//etc.
	});
});</pre>
<p>which required many selector it is best to use 1 instead since we are repeating ourselves and doing some redundant selector.</p>
<pre class="brush: jscript;">jQuery('.class').each(function(){
	var obj = jQuery(this);
	obj.html();
	obj.find('div').each(function(){
		//etc.
	});
});</pre>
<p>This is something that we often see in many plugin. Many plugin contains unnecessary selector which degrade the perform of the plugin little by little.</p>
]]></content:encoded>
			<wfw:commentRss>http://jqueryblog.net/2009/11/jquery-optimization-avoid-unnecessary-selector/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Optimization : Optimize Selector</title>
		<link>http://jqueryblog.net/2009/11/jquery-optimization-optimize-selector/</link>
		<comments>http://jqueryblog.net/2009/11/jquery-optimization-optimize-selector/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 10:39:19 +0000</pubDate>
		<dc:creator>Osman Erdo&#287;an</dc:creator>
				<category><![CDATA[jQuery Optimization]]></category>
		<category><![CDATA[Optimization]]></category>
		<category><![CDATA[Optimize Selector]]></category>
		<category><![CDATA[Selector]]></category>

		<guid isPermaLink="false">http://jqueryblog.net/?p=10</guid>
		<description><![CDATA[We can also optimize our selector other than being a bit specific on our selector. The key to optimize our selector is simple. Naive JavaScript provides two method to get id and tag (getElementById and getElementByTagName). Hence, it is always faster to use tag or id on your selector. No matter what algorithm used for [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjqueryblog.net%2F2009%2F11%2Fjquery-optimization-optimize-selector%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjqueryblog.net%2F2009%2F11%2Fjquery-optimization-optimize-selector%2F" height="61" width="51" /></a></div><p>We can also optimize our selector other than being a bit specific on our selector. The key to optimize our selector is simple. Naive JavaScript provides two method to get id and tag (getElementById and getElementByTagName). Hence, it is always faster to use tag or id on your selector. No matter what algorithm used for classes and attributes selection, the naive built-in JavaScript method will always have the upper hand. Nonetheless, classes and attribute selector have also been improved dramatically through the introduction of ’sizzling’ selector engine. However, it is always advisable to reduce the number of attribute selector as they are the slowest in many cases. On the other hand, making your selector as simple as possible is good for pure tag and id selector but may not be true for attribute and selector.</p>
<pre class="brush: jscript;">jQuery('div')
jQuery('#id')
jQuery('.classes')
jQuery('p:last')</pre>
<p>is considered as good selectors while the below might not give you very good selector result.</p>
<pre class="brush: jscript;">jQuery('body div div')
jQuery('div#id')
jQuery('#id div.classes')
jQuery('.classes p:last')</pre>
<p>It is important to treat jQuery as a helper of JavaScript instead of a new language.</p>
]]></content:encoded>
			<wfw:commentRss>http://jqueryblog.net/2009/11/jquery-optimization-optimize-selector/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

