<?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>AddyOsmani.com &#124; Where Web Businesses Grow &#187; Web Development</title>
	<atom:link href="http://addyosmani.com/blog/category/web-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://addyosmani.com/blog</link>
	<description>This is the home of Addy Osmani (Web Developer, Designer &#38; Author). Here you can find some great tips and tutorials on everything to do with web development and even a few useful code samples!</description>
	<lastBuildDate>Sun, 25 Jul 2010 14:41:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Catch404 &#8211; A jQuery And CSS3 Modal Plugin For Handling Broken Links Elegantly</title>
		<link>http://addyosmani.com/blog/catch404/</link>
		<comments>http://addyosmani.com/blog/catch404/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 22:17:42 +0000</pubDate>
		<dc:creator>Addy</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[404]]></category>
		<category><![CDATA[ajax 404]]></category>
		<category><![CDATA[ajax error]]></category>
		<category><![CDATA[ajax error handling]]></category>
		<category><![CDATA[ajax jquery]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[catch 404]]></category>
		<category><![CDATA[catch404]]></category>
		<category><![CDATA[errors]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery 404]]></category>
		<category><![CDATA[jquery 404 handling]]></category>
		<category><![CDATA[jquery error handling]]></category>
		<category><![CDATA[jquery errors]]></category>
		<category><![CDATA[yahoo]]></category>
		<category><![CDATA[yql]]></category>

		<guid isPermaLink="false">http://addyosmani.com/blog/?p=887</guid>
		<description><![CDATA[&#160; Hey guys. I&#8217;ve got a brand new jQuery plugin for you today. Let&#8217;s talk about the problem we&#8217;re going to be solving with it first: Broken links and 404 Errors are a problem that have plagued almost all websites since the dawn of the internet &#8211; they&#8217;re just a really bad user experience and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://addyosmani.com/blog/catch404/"><img height="342" border="0" width="530" alt="" src="http://addyosmani.com/blog/wp-content/uploads/catch.jpg" /></a></p>
<p>&nbsp;</p>
<p>Hey guys. I&#8217;ve got a brand new jQuery plugin for you today. Let&#8217;s talk about the problem we&#8217;re going to be solving with it first: Broken links and 404 Errors are a problem that have plagued almost all websites since the dawn of the internet &#8211; they&#8217;re just a really bad user experience and we&#8217;ve all encountered them.</p>
<p>There&#8217;s nothing attractive about clicking a link hoping that it&#8217;ll take you to your destination only to find out that the page doesn&#8217;t exist. In most cases you&#8217;re left having to figure out what to do next &#8211; do you hit the back button? do you go googling the file to see if you can find it?. In some cases they can be a total show-stopper, so what can we do to change that?.</p>
<p>Today I&#8217;d like to present a new jQuery Plugin I wrote called Catch404. Through the magic of jQuery we&#8217;re going to catch 404 errors without your users even having to leave the page and then suggest some other options they&#8217;ve got using an inline jQuery Modal window. So, why it this useful and how does it work?.</p>
<p><span id="more-887"></span></p>
<p>&nbsp;</p>
<p><a href="http://www.addyosmani.com/resources/catch404/catch404.html" style="width: 180px; color: white;" class="large blue awesome tipper" target="_blank"> View Demo</a> &nbsp;<a href="http://www.addyosmani.com/resources/catch404/catch404.release.1.01.zip" style="width: 180px; color: white;" class="large blue awesome tipper" target="_blank">Download Source</a></p>
<p>&nbsp;</p>
<p><img height="322" width="528" alt="" src="http://addyosmani.com/blog/wp-content/uploads/diagram.jpg" /></p>
<p>&nbsp;</p>
<h2>Why Is Catch404 Useful?</h2>
<p>Let&#8217;s pretend that <b>this</b> is a broken link. Can you imagine that when your users click this link, instead of them being redirected to a 404 error on your site, a friendly modal message pops up on your current page saying that it&#8217;s not available?. In that same message box you can then give them a sense of direction so that they&#8217;re not lost &#8211; you could ask them to click on a contact link to report the link&#8217;s broken, offer an alternative mirror, recommend they do a site search for the file or just say that you&#8217;re experiencing hosting issues and the file will be back up soon. The choice is completely up to you. The benefit of Catch404 is that you can offer your users a better experience when errors are encountered on your site.</p>
<p>&nbsp;</p>
<p><img height="342" width="530" alt="" src="http://addyosmani.com/blog/wp-content/uploads/catch1.jpg" /></p>
<p>&nbsp;</p>
<h2>How Does Catch404 Work?</h2>
<p>The basic idea behind Catch404 is that you perform an Ajax query for a URL and handle the response provided accordingly, so if its a 404 error, we handle this error specifically. Now because cross-domain 404 handling with jQuery is something that has often been problematic to correctly implement, achieving this isn&#8217;t as straight-forward as it should be. Instead, the plugin uses a neat trick using the Yahoo YQL Engine to access the URL for us which returns a HTML string (local URLs don&#8217;t require this hack) &#8211; thanks to James Padolsey and Christian Heillman for their work in this area. Depending on the contents of this string response, we&#8217;re then able to handle the error from the same page the user tried clicking out from. In my plugin, a modal window is used to render the error message and it&#8217;s here that you&#8217;re able to define whatever message, links or tips that you would like to offer your users regarding the 404. This offers a much better user experience than traditional 404 handling because rather than taking them somewhere with no content, you&#8217;ve now got the option to either present them with an alternative mirror or advice through the modal window.</p>
<p>&nbsp;</p>
<p><img height="320" width="530" alt="" src="http://addyosmani.com/blog/wp-content/uploads/catch3.jpg" /></p>
<h2>Let&#8217;s take a look at the jQuery under the bonnet!</h2>
<p>As you can see in the code snippet below, the most advanced piece of code in this plugin is the part that performs the above 404 handling. Because we&#8217;re connecting up to a third party site (Yahoo) in order to access this URL, there is going to be a wait of about a second or two during our query and this is the case for URLs that are valid as well as those that aren&#8217;t. To ensure your users are aware of whats going on it can be useful to display a progress overlay on your page with the label &#8216;Checking URL status..&#8217; or something similar.</p>
<div class="gmail_quote">&nbsp;</div>
<pre class="javascript" type="javascript" name="code">
//Perform the Ajax JSON call to get the Yahoo YQL response for the URL
   function performAjaxCall(url,msg,container)
  {
    if(url.match('^http')){
      msg.html(' (checking...)');

      //connect to yahoo YQL to get a response for the URL
      $.getJSON(&quot;http://query.yahooapis.com/v1/public/yql?&quot;+
                &quot;q=select%20*%20from%20html%20where%20url%3D%22&quot;+
                encodeURIComponent(url)+
                &quot;%22&amp;format=xml'&amp;callback=?&quot;,
        function(data){
          if(data.results[0]){
            var data = filterData(data.results[0]);

             //if the url passes the test, navigate to it
			donav(url);
          } else {
            msg.html(' (404!)');
            //otherwise display the modal error window
	    fourPop();
          }
        }
      );
    }
</pre>
<div class="gmail_quote"><span style="font-family: 'Times New Roman'; font-size: medium;"></p>
<pre style="word-wrap: break-word; white-space: pre-wrap;">
   </pre>
<p></span></div>
<div class="gmail_quote">and now we define our modal window function as follows:</div>
<pre type="javascript" class="javascript" name="code">
function fourPop(){

		var popWidth = 500; //dim[0].split('=')[1];
		var popID = '404message';

		$('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a class="close" href="#"><img alt="Close" title="Close Window" class="btn_close" src="images/close_pop.png" /></a>');

		var popMargTop = ($('#' + popID).height() + 80) / 2;
		var popMargLeft = ($('#' + popID).width() + 80) / 2;

		//Apply Margin to Popup
		$('#' + popID).css({
			'margin-top' : -popMargTop,
			'margin-left' : -popMargLeft
		});

		//Fade in Background
		$('body').append('
<div id="fade">&nbsp;</div>

'); .
		$('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn();  

		return false;
	};

	//Close Popups and Fade Layer
	$('a.close, #fade').live('click', function() {
	  	$('#fade , .popup_block').fadeOut(function() {
			$('#fade, a.close').remove();
	}); 

		return false;
	});

    });
  }
</pre>
<div class="gmail_quote">&nbsp;</div>
<h2>How Do I Use Catch404 On My Site Or Page?</h2>
<p><img height="375" width="500" alt="" src="http://addyosmani.com/blog/wp-content/uploads/failwhale.jpg" /></p>
<p>Using Catch404 will help you keep those broken links and fail whales at bay, but the best news is it&#8217;s relatively easy to start using straight away. All you need to do is first include jQuery and catch404.js in your page and then call the catch404() function on a selector as follows &#8211;  it should apply it to the links with that particular class or id and you&#8217;re all set. In the following case I&#8217;m using the class &#8216;ajaxcheck&#8217; to indicate links on the page that I would like checked using Catch404.</p>
<div class="gmail_quote"><b><span style="font-weight: normal;">HTML</span></b></div>
<pre name="code" type="html" class="javascript"><a class="ajaxcheck" href="somepage.html"> 

This is a link to check

</a>
</pre>
<div class="gmail_quote"><b><span style="font-weight: normal;"><br />
</span></b></div>
<div class="gmail_quote"><b><span style="font-weight: normal;">JavaScript</p>
<pre name="code" type="javascript" class="javascript">
$(document).ready(function()
{

$(&quot;.ajaxcheck&quot;).catch404();

});
</pre>
<p></span></b></div>
<h2>Demo and Download</h2>
<p>To see a fully featured demo of Catch404 in action, just click the demo button below. You can also download the plugin and source files via the Download button if you&#8217;d like to start using it in your projects.</p>
<p>&nbsp;</p>
<p><a href="http://www.addyosmani.com/resources/catch404/catch404.html" style="width: 180px; color: white;" class="large blue awesome tipper" target="_blank"> View Demo</a> &nbsp;<a href="http://www.addyosmani.com/resources/catch404/catch404.release.1.01.zip" style="width: 180px; color: white;" class="large blue awesome tipper" target="_blank">Download Source</a></p>
<p>&nbsp;</p>
<p>Thanks for reading and I hope Catch404 helps you to keep those broken links, 404&#8242;s and fail whales at bay. To share this article with your friends click <a href="http://addyosmani.com/blog/catch404/" class="retweet">Catch404 &#8211; A jQuery And CSS3 Modal Plugin For Handling Broken Links Elegantly</a> now. Good luck with your projects!</p>
<p>- Addy.</p>
]]></content:encoded>
			<wfw:commentRss>http://addyosmani.com/blog/catch404/feed/</wfw:commentRss>
		<slash:comments>40</slash:comments>
		</item>
		<item>
		<title>Web Design For Every Culture (with jQuery And the Google Translate API)</title>
		<link>http://addyosmani.com/blog/web-design-for-every-culture/</link>
		<comments>http://addyosmani.com/blog/web-design-for-every-culture/#comments</comments>
		<pubDate>Sun, 20 Jun 2010 15:30:08 +0000</pubDate>
		<dc:creator>Addy</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[cultural web design]]></category>
		<category><![CDATA[culture]]></category>
		<category><![CDATA[designing]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[google translate]]></category>
		<category><![CDATA[google translate api]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery localization]]></category>
		<category><![CDATA[local]]></category>
		<category><![CDATA[local design]]></category>
		<category><![CDATA[localization]]></category>
		<category><![CDATA[translate]]></category>
		<category><![CDATA[translation]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[web design culture]]></category>

		<guid isPermaLink="false">http://addyosmani.com/blog/?p=850</guid>
		<description><![CDATA[Hey guys. Today I&#8217;d like us to look at a topic that can sometimes be overlooked in web design projects &#8211; the power of designing based on culture. Lets start off with a simple question &#8211; do you know how many of your visitors come from countries where English isn&#8217;t their first language?. I didn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://addyosmani.com/blog/web-design-for-every-culture"><img height="342" border="0" width="530" src="http://addyosmani.com/blog/wp-content/uploads/culture(1).jpg" alt="" /></a></p>
<p>Hey guys. Today I&#8217;d like us to look at a topic that can sometimes be overlooked in web design projects &#8211; the power of designing based on culture. Lets start off with a simple question &#8211; do you know how many of your visitors come from countries where English isn&#8217;t their first language?.</p>
<p>I didn&#8217;t until quite recently and the statistics really surprised me. Over half..that&#8217;s right..over<strong> </strong>half of the visitors to my site come from countries with a different first language (and a different culture). Knowing this opens up a number of new opportunities for site owners that find themselves a similar boat.</p>
<p><span id="more-850"></span></p>
<p>For starters, you can improve the experience these visitors get on your site by simply introducing translated versions of your articles or even a design that compliments their culture. Not only this but you can also open your site up to a much much broader audience, simply by making your posts easily available in multiple languages and making your content location friendly.</p>
<p>In this article, we&#8217;re first going to discuss the concept of localization in more detail with the help of Christian Arno (an expert in this field from translation company Lingo24) and I&#8217;m then going to show you how you can start offering ajax translation of your posts or pages using jQuery and the Google Translation API.</p>
<p>&nbsp;&nbsp; &nbsp;</p>
<p><strong>Web design for every culture </strong></p>
<p>&nbsp;</p>
<p>There are 1.8bn people now online around the world (according to <a href="http://www.internetworldstats.com/">Internet World Stats</a>), of which only 495.8m are English speakers. That means that as soon as your site is online, it&rsquo;s accessible by all of those people, but less than a third of your potential audience will be able to read your site if you stick to English as your only language.</p>
<p>This is especially important if you&rsquo;re an online business, since a study by the <a href="http://www.commonsenseadvisory.com/Research/Report_Abstracts/060926_R_global_consumer/tabid/1258/Default.aspx">Common Sense Advisory</a> found that 85% of online shoppers, even those who speak multiple languages, will only buy from a site where they can read about the product in their own native language.</p>
<p>If you want to effectively sell to all those online shoppers who aren&rsquo;t native English speakers, then the key is to localise. You need to identify exactly which countries will have a gap in the market for your product or service, and then create individual domains for each country, with local URLs, and preferably hosted on servers in the target country (to assist with your local search engine page rankings).</p>
<p>When it comes to building localised sites, there are a few things to keep in mind. You can&rsquo;t just create the one template for every URL and simply switch the language, as different cultures have different requirements and preferences when it comes to website design. Your aim should be to create a template which will stay consistent in its branding, but also be flexible enough to change slightly between local versions. Here are a few of the points you should keep in mind.</p>
<p>&nbsp;</p>
<p><strong>Multicultural design</strong></p>
<p>&nbsp;</p>
<p>There are fundamental differences in design between sites designed for <a href="http://en.wikipedia.org/wiki/High_context_culture">&lsquo;High Context&rsquo;</a> and <a href="http://en.wikipedia.org/wiki/Low_context_culture">&lsquo;Low Context&rsquo;</a> cultures. For instance, take a look at the differences between Youtube, which was designed with a Western, &lsquo;Low Context&rsquo; culture in mind, and the Chinese version <a href="http://www.tudou.com/">Tudou</a>. Playing a video on Youtube involves the clip simply playing on your main screen, with the option for full screen &#8211; but playing&nbsp; a video on Tudou takes you into a virtual cinema, with a background designed to look like a theatre and a host of pop-up animations.</p>
<p>This is a good illustration of the fundamental difference between &lsquo;low context&rsquo; cultures, which like minimalism and straight-up information, and &lsquo;high context&rsquo; cultures, which get a lot more of their information from the background or context of a site.</p>
<p>Essentially, you need to look at your competitors in each market to see what they&rsquo;re doing successfully with their site designs, and then one-up them, while keeping an element of consistent branding across every site &ndash; for instance, look at the differences and similarities between Coke&rsquo;s <a href="http://www.coca-cola.se/">Swedish</a> site and its <a href="http://www.coca-cola.com.cn/">Chinese</a> site.</p>
<p>&nbsp;</p>
<p><strong>Navigation and colour</strong></p>
<p>&nbsp;</p>
<p>Your main issue with navigation is going to be the switch between left-to-right and right-to-left languages. Handily, cascading style sheets (CSS) make it quite easy to switch the direction of your text, or to flip your template, by adding the right-to-left dir=&quot;rtl&quot; attribute to the necessary areas &ndash; but more on CSS later.&nbsp; If you use a horizontal navigation bar, that will prevent problems caused by having to move your navigation bar from one side to the other. Alternatively, keeping your site as symmetrical as possible will save you from having to redesign your page when switching the direction of your language.</p>
<p>You should also think carefully about the colour scheme you go for with each site. Obviously you don&rsquo;t want to be changing colours drastically between each site, but you should also be aware that colours have different meanings in different cultures, as shown by this <a href="http://www.globalization-group.com/edge/resources/color-meanings-by-culture/?utm_source=Translation+Bloopers+%26+Blunders+%7C+Translation+%26+Localization+Tips+%7C+Free+Subscription+%7C+GGI&amp;utm_campaign=c7ef00a4c2-Translation_Tips_2010-021_05_25_Colors&amp;utm_mediu">graph</a>. Going for a light coloured background with dark text is your best bet &ndash; and blue is generally considered to be the most universally acceptable colour.</p>
<p>&nbsp;</p>
<p><strong>CSS and Unicode UTF-8</strong></p>
<p>&nbsp;</p>
<p>Keeping your content separate from your design is rather handy when you have to change your text and images between multiple sites, so that&rsquo;s why CSS is your best choice for cross-cultural web designing. You&rsquo;ll also need a character encoder that can handle multiple scripts, from Latin, to Cyrillic, to Arabic and Simplified Chinese. Unicode UTF-8 does all that and more (90 scripts in total), and is supported by all the major browsers, making it your best bet as a character encoder.</p>
<p>&nbsp;</p>
<p><strong>Geolocation</strong></p>
<p>&nbsp;</p>
<p>Imagine being able to channel your visitors from any region in the world directly to a web page that&rsquo;s localised for their language and culture. Geolocation can identify a web surfer&rsquo;s location by checking the country in which their IP address is registered, and there are a number of companies &ndash; such as Hexa Software&rsquo;s <a href="http://www.ip2location.com/free.asp">IP2Location</a> and <a href="http://www.digitalenvoy.net/">Digital Envoy</a> -&nbsp; which collate IP addresses and can lease you access to integrated databases that allow you to funnel site visitors directly to their localised domain.</p>
<p>The only problem is that IP addresses aren&rsquo;t always hosted in the country where the end user resides &ndash; for instance, lots of servers are hosted in China, so while a visitor may live in Germany, their IP address will show up as being from China, and if you use geolocation you&rsquo;ll end up automatically routing them to your Chinese site.</p>
<p>In any case, if you have each localised domain hosted on a server in its target country, it will appear as the preferred option in the local Google search &ndash; for instance, if you have www.yourcompany.fr hosted on a server in France, when people search for &lsquo;your service&rsquo; on Google.fr, they&rsquo;ll get your French site, rather than www.yourcompany.com.</p>
<p>&nbsp;</p>
<p><strong>Translation and copy-writing for localised sites</strong></p>
<p>&nbsp;</p>
<p>Most importantly, you need to make sure that your content is correct and appropriate for each local site. While it may be tempting to just run your English copy through <a href="http://translate.google.com/">Google Translate</a> and post up the results, that&rsquo;s not your best option for a trustworthy, reliable looking site.</p>
<p>Machine translation is often fine to get the gist of a piece of foreign language text, but when it comes to marketing material, which requires a fine balance to be trustworthy and also sell to the customer, you&rsquo;re best off getting a professional who lives in the target country to either write your copy from scratch, or translate it and check for any potential points of offense or &lsquo;wrong notes&rsquo;. The last thing you want is to commit a translation faux pas, such as when General Motors introduced their new Chevy Nova into the Mexican market, obviously not realising that &lsquo;no va&rsquo; in Spanish means &lsquo;no go&rsquo;.</p>
<p>&nbsp;</p>
<p><strong>Translation widgets and inline translation</strong></p>
<p>&nbsp;</p>
<p>If you&rsquo;re running off a tight budget, though, and can&rsquo;t afford the expense of professional translation and copy writing, there&rsquo;s always the option of adding a translation widget to your home page, or using inline translation. There are plenty of translation engines out there, and by simply copying a bit of code into your site you&rsquo;ll get a box that lets visitors know they can automatically translate the text into any language.</p>
<p>Google Translate is probably the best known &ndash; and was the most popular in a recent <a href="http://www.globalbydesign.com/blog/2010/05/17/google-bing-and-babelfish-whats-the-best-translation-engine/">review</a> of translation engines &ndash; but it&rsquo;s not your only option. Microsoft also has a widget for <a href="http://www.microsofttranslator.com/widget/">Windows Live Translator</a>, and then there&rsquo;s widgets for <a href="http://handheld.softpedia.com/get/Internet-Utilities/Bing-Widget-79295.shtml">Bing</a>, which was voted superior for Italian and German translation, and pioneer <a href="http://www.widgetbox.com/widget/altavista-babelfish-site-translator">Babelfish</a>, which rates well for Chinese to English translation. There are plenty of others available with different specialisations, most of which are stocked at Widget Box.</p>
<p>Alternatively, for a smoother interaction experience, if you&rsquo;re up to date with inline functions you can build inline translation code into your site to offer your visitors an instantly localised browsing experience. Javascript libraries like jQuery offer a host of useful advice on how to use asynchronous JavaScript and XML (Ajax) to incorporate code into your site and create rich and engaging websites that adapt intuitively to your visitors&rsquo; language needs and offer your visitors a high definition, &lsquo;no refresh&rsquo; browsing experience.</p>
<p>&nbsp;</p>
<p><strong>Harnessing the Google Translation API with jQuery</strong></p>
<p>To add instant jQuery translations to your site, I recommend the use of the jQuery Translate plugin. This nicely interfaces with the Google Translation API giving you instant access to translation of your content across a number of different languages. Here&#8217;s a <a href="http://jsbin.com/ozenu/edit">demo</a> of it in action on JS-Bin. To get started, first download the translate plugin <a href="http://code.google.com/p/jquery-translate/">here.</a></p>
<p>Next, include the plugin after jQuery as follows:</p>
<pre class="javascript" name="code">
&lt; script type=&quot;text/javascript&quot; src=&quot;js/jquery-1.4.2.min.js&quot;&gt;
&lt; script type=&quot;text/javascript&quot; src=&quot;js/jquery.translate-1.3.9.js&quot;&gt;
</pre>
<p>If you want to use the plugin on page load in most cases you can call it inside $(document).ready() but in some cases you have to define a callback function to be executed when the Language API is loaded. It&#8217;s not $(document).ready() but $.translate.ready():</p>
<pre class="javascript" name="code">
$(document).ready(function(){
  //this will work,
  //returns a jQuery object and translates the text when the Language API is loaded
  $('body').translate('english');

  //this will work too,
  //returns an internal object and translates the text when the Language API is loaded
  $.translate( 'some text', 'de', {
    complete: function(){
                console.log( this.translation )
    }
  });

  //this won't (always) work!
  //the Language API may not be loaded, the return value cannot be determined
  $.translate.getLanguages();

  //this will work, as it will be executed when the Language API is loaded
  $.translate.ready(function(){
    $.translate.getLanguages()
  })

  //you can also use a shorter alias as in jQuery:
  $.translate(function(){
    $.translate.getLanguages()
  })

})
</pre>
<p>
As you can see above you can translate an html element (first example) or only some text (second example). This plugin is great because you could easily add in a few flag icons to the top of your articles and trigger the Google Translate API to translate your post&#8217;s content via Ajax. Remember that if you&#8217;re applying the translate function to &#8216;body&#8217;, your layout may need to be flexible enough to accomodate longer text labels. The safest way to apply it in my opinion would be to just the post-container or in the case of a standard site, the container of your main text. Use your best judgement here!</p>
<p>&nbsp;</p>
<p><strong>In conclusion</strong></p>
<p>By researching your markets and getting some assistance from in-country experts before you build and launch your localised sites, you can save yourself a lot of hassle later, and have a much better chance of finding success with your localised sites first time, no matter what culture you&rsquo;re marketing to.</p>
<p><strong><br />
About the guest author</strong></p>
<p>Christian Arno is the founder and Managing Director of <a href="http://www.lingo24.com/">global translation agency and localisation specialists</a> Lingo24. Launched in 2001, Lingo24 now has over 120 employees spanning four continents and clients in over sixty countries. In the past twelve months, they have translated over thirty million words for businesses in every industry sector and their projected turnover for 2010 is &pound;6.3m.</p>
]]></content:encoded>
			<wfw:commentRss>http://addyosmani.com/blog/web-design-for-every-culture/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>jQuery &amp; CSS Sprite Animation Explained In Under 5 Minutes</title>
		<link>http://addyosmani.com/blog/jquery-sprite-animation/</link>
		<comments>http://addyosmani.com/blog/jquery-sprite-animation/#comments</comments>
		<pubDate>Mon, 31 May 2010 01:03:19 +0000</pubDate>
		<dc:creator>Addy</dc:creator>
				<category><![CDATA[Under 10 Minutes]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[animated]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[css sprite animation]]></category>
		<category><![CDATA[css sprites]]></category>
		<category><![CDATA[examples]]></category>
		<category><![CDATA[javascript sprite]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery sprite animation]]></category>
		<category><![CDATA[sprite]]></category>
		<category><![CDATA[spritely]]></category>
		<category><![CDATA[sprites]]></category>

		<guid isPermaLink="false">http://addyosmani.com/blog/?p=778</guid>
		<description><![CDATA[&#160; Today we&#8217;re going to take a look at sprite animation. There&#8217;s been a lot of talk this year about the future of technologies like Adobe&#8217;s Flash and for good reason &#8211; with the performance of JavaScript frameworks having come so far since they were first conceived, it&#8217;s now possible to create equally as powerful [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://addyosmani.com/blog/jquery-sprite-animation/"><img width="530" height="342" border="0" src="http://addyosmani.com/blog/wp-content/uploads/csssp.jpg" alt="" /></a></p>
<p>&nbsp;</p>
<p>Today we&#8217;re going to take a look at sprite animation. There&#8217;s been a lot of talk this year about the future of technologies like Adobe&#8217;s Flash and for good reason &#8211; with the performance of JavaScript frameworks having come so far since they were first conceived, it&#8217;s now possible to create equally as powerful animations and effects without needing to use any third party plugins.In today&#8217;s screencast I&#8217;m going to show you what a sprite is and just how easy it can be to create an entire animated scene using jQuery, CSS &amp; Sprites. You&#8217;ll also get to see some pretty cool out-in-the-wild examples of jQuery Sprite Animation in action, so why not check it out in my screencast below!</p>
<p><span id="more-778"></span></p>
<p>&nbsp;</p>
<p><object width="500" height="345" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"><param value="http://screenr.com/Content/assets/screenr_1116090935.swf" name="movie" /><param value="i=67218" name="flashvars" /><param value="true" name="allowFullScreen" /><embed width="500" height="345" pluginspage="http://www.macromedia.com/go/getflashplayer" allowfullscreen="true" flashvars="i=67218" src="http://screenr.com/Content/assets/screenr_1116090935.swf"></embed></object></p>
<p>Demos and text are available for anyone that wants to read/see them in the rest of the post.</p>
<p>&nbsp;</p>
<p><a href="http://www.addyosmani.com/resources/sprites/demo.html" style="width: 180px; color: white;" class="large blue awesome tipper" target="_blank"> View Demo</a> &nbsp;<a href="http://www.addyosmani.com/resources/sprites/spritesin5mins.zip" style="width: 180px; color: white;" class="large blue awesome tipper" target="_blank">Download Source</a></p>
<p>&nbsp;</p>
<p><img width="500" border="0" src="http://www.addyosmani.com/images/gopher.jpg" alt="" /></p>
<p>&nbsp;</p>
<p>Today&#8217;s animations are created using a really useful jQuery plugin called Spritely. You can download the Spritely plugin <a href="http://spritely.net/download/">here</a>. Spritely allows you to create your own animations using two simple functions.The pan() function which lets you pan (move) an image across the screen in a particular direction; and the sprite() function which lets you work with multiple frames and add more complex behaviours to your animations. In the screencast I show you how to first use pan() to create a moving silhouette of a city and then we use the sprite() function to add an animated plane to it. To help you with your own creations, I&#8217;m including code for both of these below.</p>
<p>&nbsp;</p>
<h2>Basic Example using Pan()</h2>
<p>&nbsp;</p>
<p>How complex your animations can get really depend on what you&#8217;re trying to achieve. If you&#8217;re trying to create a moving landscape scene, you&#8217;ll probably be able to knock that out fairly quickly because all you need to do is pan your images across the screen at a particular speed.</p>
<p><img width="500" border="0" src="http://www.addyosmani.com/images/citymove.jpg" alt="" /></p>
<p>Here&#8217;s the sample code I used to create the city skyline panning effect:</p>
<p>&nbsp;</p>
<p><strong>The jQuery</strong></p>
<pre class="javascript" name="code">
			$(document).ready(function() {
				$('#city').pan({fps: 30, speed: 2, dir: 'left'});
				});
</pre>
<p>&nbsp;</p>
<p><strong>The HTML</strong></p>
<pre class="html" name="code">
<div id="city">&nbsp;</div>
</pre>
<p>&nbsp;</p>
<p><strong>The CSS</strong></p>
<pre class="css" name="code">
		body {
			background: #fff;
			margin:0 auto;
		}

		/*City Silhouette*/
		#city {
			position: absolute;
			width: 99%;
			height: 416px;
			background: transparent url(city.png) 0 130px repeat-x;
			border: 1px solid black;
		}
</pre>
<p>&nbsp;</p>
<h2>Advanced Example Using Pan() &amp; Sprite()</h2>
<p>&nbsp;</p>
<p>If however you&#8217;d like to create something a little more detailed like a 2D or 3D character with movement, you&#8217;ll need to use a package like Maya, 3DMax or even Flash to output the animation as frames with a transparent background. Next, follow my steps below to create the jQuery animation for it.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<ol>
<li>Output your frames as transparent PNG files to a directory on your drive. Because animation can sometimes be a memory intensive task, you&#8217;ll want to minimize this as much as possible. This can be achieved by outputting 1 frame for every 5-15 in your original animation. Don&#8217;t worry! The Spritely plugin supports setting custom frame-rates so you can still make your final animation look relatively smooth.</li>
<li>Use a Sprite Generation tool such as <a href="http://css-sprit.es">CSSSprit.es</a> or <a href="http://csssprites.com/">CSSSprites.com</a> to stitch your frames together as a single image file. Try to keep the final filesize down to within a few megabytes (I would say 2MB should really be the higher end of that filesize).</li>
<li>Next animate your content using Spritely as I did in my demo. You can find some sample code for this below.</li>
</ol>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><img width="500" border="0" src="http://www.addyosmani.com/images/skyline.jpg" alt="" /></p>
<p><strong>The jQuery</strong></p>
<pre class="javascript" name="code">
  (function($) {
			$(document).ready(function() {

			    /* City 1 */
				$('#city1').pan({fps: 30, speed: 1, dir: 'right'}); 

				/* City 2 - This gives the animation a depth of perspective
				as one city silhoette is slightly away from the other*/
				$('#city2').pan({fps: 30, speed: 2, dir: 'right'}); 

				/*The clouds and sky*/
				$('#sky').pan({fps: 30, speed: 0.5, dir: 'right'}); 

				/*The Plane animation*/
				var stage_left = (($('body').width() - 866) / 2);
				var stage_top = 30;

				/* Spritely's sprite function allows you to define
				more complex animations which contain more than 1
				frame. You can also use the spRandom feature to define
				random behaviour.
				*/
				$('#plane1').sprite({fps: 8, no_of_frames: 14})
					.spRandom({
						top: 40,
						left: stage_left + 20,
						right: 400,
						bottom: 140,
						speed: 3500,
						pause: 1000
					});

			});
		})(jQuery);
  </pre>
<p>&nbsp;</p>
<p><strong>The HTML</strong></p>
<pre class="html" name="code">
<div id="sky">&nbsp;</div>
<div id="city1">&nbsp;</div>
<div id="city2">&nbsp;</div>
<div id="plane1">&nbsp;</div>
<div id="content">
<div id="leftcontent">
<div id="rightcontent">&nbsp;</div>
</div>
</div>
</pre>
<p>&nbsp;</p>
<p><strong>The CSS</strong></p>
<pre class="css" name="code">
			body
			{
			background: #fff;
			margin:0 auto;
		     }

		#sky {
		  position:absolute;
		  width:100%;
		  height: 416px;
		  background: transparent url(sky.jpg) 0 0px repeat-x; 

		}

		#city {
			position: absolute;
			width: 100%;
			height: 416px;
			background: transparent url(city.png) 0 130px repeat-x;

		}

		#city2 {
			position: absolute;
			width: 100%;
			height: 416px;
			background: transparent url(city2.png) 0 130px repeat-x;
		}

		#plane1 {
			position: absolute;
			width: 730px;
			height: 167px;
			background: transparent url(planesprite.png) 0 50px no-repeat;
		}

		#content {

		   width: 100%;
		   position:relative;
		   clear:both;
		}

		#leftcontent {
		  width:70%;
		}

		#rightcontent {
		  width:30%;
		  background-color:blue;
		}
</pre>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>And thats it!. As with all my &#8216;Under 5 Minutes&#8217; series, you obviously won&#8217;t have learned absolutely everything there is to know about sprite animation, but hopefully you will have picked up many of the basics. Please feel free to download the source files and play around with them &#8211; I hope they come in useful!</p>
<p>&nbsp;</p>
<h2>Demo &amp; Download</h2>
<p>&nbsp;</p>
<p><a href="http://www.addyosmani.com/resources/sprites/demo.html" style="width: 180px; color: white;" class="large blue awesome tipper" target="_blank"> View Demo</a> &nbsp;<a href="http://www.addyosmani.com/resources/sprites/spritesin5mins.zip" style="width: 180px; color: white;" class="large blue awesome tipper" target="_blank">Download Source</a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h2>Conclusion</h2>
<p>&nbsp;</p>
<p>This tutorial was created to demonstrate how to create animations in jQuery using sprites. This powerful technique is a simple, effective way of creating cross-browser friendly animations that don&#8217;t need to rely on Flash or any third-party plugins to function. To see more demos of how Spritely is being used to add rich animated experiences to web pages, feel free to have a look at the Spritely gallery <a href="http://spritely.net/gallery/">here</a>. If you enjoyed today&#8217;s post, please share it with your friends and colleagues by clicking <a href="http://addyosmani.com/blog/jquery-sprite-animation/" class="retweet">jQuery &amp; CSS Sprite Animation Explained In Under 5 Minutes</a></p>
]]></content:encoded>
			<wfw:commentRss>http://addyosmani.com/blog/jquery-sprite-animation/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>jQuery Vs. JavaScript &#8211; The Masters Share Their Views On Vanilla JS</title>
		<link>http://addyosmani.com/blog/javascriptuncovered/</link>
		<comments>http://addyosmani.com/blog/javascriptuncovered/#comments</comments>
		<pubDate>Tue, 25 May 2010 00:03:05 +0000</pubDate>
		<dc:creator>Addy</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[chris coyier]]></category>
		<category><![CDATA[comparison]]></category>
		<category><![CDATA[david walsh]]></category>
		<category><![CDATA[debate]]></category>
		<category><![CDATA[james padolsey]]></category>
		<category><![CDATA[janko]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[javascript tutorial]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery team]]></category>
		<category><![CDATA[jquery tips]]></category>
		<category><![CDATA[jquery tricks]]></category>
		<category><![CDATA[jquery vs javascript]]></category>
		<category><![CDATA[marco kupier]]></category>
		<category><![CDATA[mootools]]></category>
		<category><![CDATA[should i learn javascript]]></category>
		<category><![CDATA[soh tanaka]]></category>

		<guid isPermaLink="false">http://addyosmani.com/blog/?p=724</guid>
		<description><![CDATA[&#160; We&#8217;ve got a really great post for you today guys. We&#8217;re going to explore whether it&#8217;s fundamentally important for designers and developers to understand how to use vanilla JavaScript and not just it&#8217;s derivative frameworks and libraries such as jQuery and MooTools. You might be asking &#8216;why?&#8217;, but read on and you&#8217;ll find out!. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://addyosmani.com/blog/javascriptuncovered/"> <img border="0" alt="" src="http://addyosmani.com/blog/wp-content/uploads/masters.jpg" style="border: 0px none; display: inline;" /> </a></p>
<p>&nbsp;</p>
<p>We&#8217;ve got a really great post for you today guys. We&#8217;re going to explore whether it&#8217;s fundamentally important for designers and developers to understand how to use vanilla JavaScript and not just it&#8217;s derivative frameworks and libraries such as jQuery and MooTools. You might be asking &#8216;why?&#8217;, but read on and you&#8217;ll find out!. Because this is a topic that can invoke passion on both sides of the debate, I&#8217;ve asked a few familiar names to join the discussion including David Walsh, Chris Coyier, Marco Kupier, Janko Javanovic and James Padolsey. All of these authors use jQuery regularly and are in a good position to advise on the pros and cons of knowing vanilla JS.<br />
<span id="more-724"></span> Before we begin, I&#8217;d like to take this opportunity to introduce James Jackson as a new member of the site team who&#8217;s contribution to this post was invaluable. So let&#8217;s get started!.</p>
<p>We all know that JavaScript frameworks have made it significantly easier to create rich animated effects and interfaces in our web pages &#8211; the type of thing which previously would have taken a lot longer if we were writing everything from scratch. I&#8217;ve seen coders creating sliding effects and javascript animation for over 10 years but until now, the effort required to achieve the effects through plain JS were sometimes considered too much hassle. Throw in cross-browser compatibility issues and you had a nightmare. jQuery, MooTools and other frameworks have changed this.</p>
<p>They haven&#8217;t altered the underlying javascript (it&#8217;s important to point this out), but they have introduced an easier layer of access to JS and it&#8217;s core functionality which was previously missing. </p>
<p>The question we&#8217;re asking today is whether it&#8217;s important for people who use libraries like jQuery to understand how&nbsp; the underlying javascript works. My personal opinion is that it is &#8211; whilst you can &quot;get by&quot; knowing how to use many of the basic functins jQuery offers, I think that there&#8217;s a certain power in knowing why a particular selector should be used over another or how to create something from scratch if jQuery doesn&#8217;t particularly support executing it well.</p>
<p>Let&#8217;s now delve into this topic further with James.</p>
<p><span style="font-size: x-large;"><strong>jQuery Vs. JavaScript</strong></span></p>
<p>jQuery is the key to the Web 2.0 lock.</p>
<p>I&#8217;m not afraid to say it, and furthermore, I&#8217;m not afraid to utilize a well known buzz term like, &quot;Web 2.0&quot;.&nbsp; Now, throughout this article, I&#8217;m going to be referencing jQuery quite a bit but that&#8217;s only because it&#8217;s my favorite Javascript library and the one I know the best.&nbsp; You could easily support any number of other libraries in a similar fashion.</p>
<p>That said, jQuery has helped a whole new generation of coders approach that ever alluring, and always intimidating field of web scripting.&nbsp; Browsers themselves are greatly measured by how well (and quickly!) they can support Javascript, and jQuery alike.</p>
<p>Most people reading this article are likely already quite familiar with jQuery, so I&#8217;d like to take a generous step backward and talk about what lies beneath it.&nbsp; Javascript itself.</p>
<p>We all understand Javascript in different ways, possible by the vast variability of its usefulness, but at its core Javascript really showcases itself as a powerful, easy to use scripting language that is more accessible than many of its influences.&nbsp; The notorious C, and its derivitaves, is often understood as a pipe dream to many modern developers and yet every single Javascript programmer utilizes a syntax almost indisinguishable from C&#8217;s without ever realizing it.</p>
<p>jQuery further blurs the lines with its own, innovative syntax which causes its biggest strength to also be its biggest weakness: approachability.&nbsp; Within any system, its a common rule of thumb that the simpler it is to use, the more removed from the source material it gets.&nbsp; jQuery is no exception.</p>
<p>A great deal of jQuery programmers I have known since its inception have been drawn to jQuery for its simplicity, betwitched by its seeming ability to allow the average web designer to magically produce Javascript effects that were otherwise impossible.&nbsp; When a client wants something to zoom across the screen, or to showcase a slideshow of photographs, jQuery answers the call.&nbsp; With a few script includes and some copying and pasting, its not only possible but extremely effective.&nbsp; With the overwhelming amount of customization that jQuery Plugin developers put into their modules, coders can even have intricate control over these effects without ever touching a single line of raw Javascript.&nbsp; jQuery takes care of all of it for you.</p>
<p>The problem herein lies in the moment that every late-night script surgeon will inevitably encounter: when something doesn&#8217;t do *exactly* what we need it to.&nbsp; We try tweaking the settings, finding an alternative plugin or scaring ourselves witless looking at the wall of code within the plugins themselves.</p>
<p>Don&#8217;t worry &#8212; we&#8217;ve all been there.&nbsp; This frustration, however, doesn&#8217;t have to halt our programming process and can instead offer an exciting challenge.&nbsp; If we understand the underlying code well enough, then virtually nothing is outside of our grasp within the world of Javascript.</p>
<p>Virtually any element within a web page, through the most popular operating system on the planet &#8212; the web browser, is accessible and can have its attributes changed.&nbsp; New elements can be created, manipulated and even removed from existence.&nbsp; Your keyboard becomes your brush and the browser becomes your canvas.&nbsp; Literally, even now with HTML5.</p>
<p>jQuery provides a proverbial &#8216;Paint by Numbers&#8217; tool for us, but when we need to break away from the lines and numerical digits, the paper beneath needs to be understood as well.</p>
<p>I&#8217;m sure it goes without saying, but I&#8217;d bet that the average jQuery enthusiast without extensive knowledge of Javascript doesn&#8217;t fully realize what jQuery is: a collection of Javascript.&nbsp; It&#8217;s not a new environment, it&#8217;s not an expansion pack; it&#8217;s a big pile of Javascript that draws a curtain between you and Javascript.&nbsp; All the web&#8217;s a stage, and the DOM is its players.</p>
<p>Most readers, who are familiar with jQuery know of the $() identifier.&nbsp; It allows you to select, or create/remove, any element on a webpage and manipulate it.&nbsp; If we want to grab an element like this:</p>
<pre name="code" class="javascript">
<div id="example">&nbsp;</div>
</pre>
<p>Then all we require to select it is:</p>
<pre class="javascript" name="code">
$(&quot;#example&quot;)</pre>
<p>From there, we can affect it in the multitude of ways that jQuery provides.&nbsp; What does this $() mean, though, exactly?&nbsp; How does it work?&nbsp; Is it magic?</p>
<p>In all actuality, $()&#8217;s usefulness, speed and versatility is bound only by your understanding of it. Before we delve further into this, lets remember that $() is a jQuery selector which can take more than one parameter, element IDs separated by commas and returns elements as objects in an array. For the sake of simplicity, let&#8217;s imagine that we&#8217;re just trying to get the very first element matched in the DOM with a particular ID (in jQuery this translates to $(&#8216;#example&#8217;)[0]) In this case, we could achieve this in standard vanilla JavaScript as follows:</p>
<pre class="javascript" name="code">
document.getElementById(&quot;example&quot;)</pre>
<p>Now, because Javascript has this functionality included right into its core, calling elements in this way greatly speeds up jQuery (tests show that getElementById is faster than standard selection in jQuery, however, this is only when you want to grab elements of a particular ID rather than a collection of elements).&nbsp; Because we&#8217;re making it so that jQuery doesn&#8217;t have to churn through functions and translators, and instead can just use Javascript&#8217;s built-in functionality to jump right to the item. Again, let&#8217;s remember that jQuery actually provides us with ways of accessing elements by much more advanced selection techniques, however, if you know exactly what you&#8217;re after, vanilla can help.</p>
<p>What does this mean to you?&nbsp; SPEED.&nbsp;</p>
<p>By understanding this aspect of Javascript, you can literally cut whole chunks of processing time out of your plugins and scripts. We should note however that jQuery&#8217;s use of the Sizzle selector engine has done it&#8217;s best to eliminate redundancy when looking up elements in the DOM, but there are still gains to be made for those that understand the underlying javascript.</p>
<p>The Animate feature of jQuery, as mentioned above, allows us to move any element on a page around the browser&#8217;s view port with only a few lines of code:&nbsp;</p>
<pre name="code" class="javascript">
$(&quot;#element&quot;).animate({ left: 100px; });</pre>
<p>This makes moving #element 100 pixels to the right extremely simple.&nbsp; However, let&#8217;s assume that we want to add a wavy-animation to our element, so it doesn&#8217;t mearly glide to the left but instead waves around (as though our precious #element has had a few to many Box Model Martini&#8217;s).&nbsp; This is possible with jQuery, of course, and there are even plugins available to accomplish it.&nbsp; Let&#8217;s further assume that either we have a very specific vision for how it will animate or (more likely) our client does.</p>
<p>Either way, time will be spent.&nbsp; Whether its time spent looking for the appropriate plugin, or writing the code ourself.</p>
<p>If we briefly break down jQuery.Animate, we get a very simple process: an event occurring within an interval or timer, selecting the element (by ID) and changing its &#8216;style.left&#8217; property incrementally through CSS.&nbsp;. Animate() of course supports a wide range of features including intervals, easing and other plugins, but if we wanted to take animate at it&#8217;s most basic and wanted to re-create this in basic javascript (moving an element across the screen), lets see how we cold create that code.</p>
<pre class="javascript" name="code">
var example = null; // object

function doMove() {
  example.style.left = parseInt(example.style.left)+1+'px';
  setTimeout(doMove,20); // call doMove in 20msec
}

function init() {
  example = document.getElementById('example'); // get the &quot;example&quot; object
  example.style.left = '0px'; // set its initial position to 0px
  doMove(); // start animating
}

window.onload = init;
</pre>
<p>&nbsp;</p>
<p>And we&#8217;re done.&nbsp;Now obviously, there is a LOT more going on behind the animate function &#8211; it supports chaining, easing plugins and a greater level of modification than simply moving an item across the screen, but in its most basic form, that&#8217;s what we&#8217;re trying to achieve.</p>
<p>This is a more advanced example, so what if you want to mimic a much simpler function of jQuery?&nbsp; Say, the hide() command?</p>
<p>&nbsp;</p>
<pre name="code" class="javascript">
$(&quot;example&quot;).hide();</pre>
<p>&nbsp;</p>
<p>This comes in really handy, as you can hide elements that are not currently needed in your application.&nbsp; What does this function *do* exactly, though?&nbsp; As with so many things, the better we understand something, the better we can innovate.</p>
<p>Much of what makes Web Apps so functional (and, let&#8217;s admit it, pretty) is affecting their CSS attributes: their color, their opacity, their location on the screen, etc.&nbsp; The hide() function affects one of the most used CSS attributes: display.</p>
<p>To translate the above hide command, we could also imagine it like this:&nbsp;</p>
<p>&nbsp;</p>
<pre name="code" class="javascript">
 $(&quot;#example&quot;).css(&quot;display&quot;,&quot;none&quot;);</pre>
<p>&nbsp;</p>
<p>Of course, the hide() command gives you more control over the effect, but by using the css() command instead, we can now do some pretty interesting things, such as:</p>
<p>Blend an object in with the text, rather than putting it on its own line:</p>
<p>&nbsp;</p>
<pre name="code" class="javascript">
 $(&quot;#example&quot;).css(&quot;display&quot;,&quot;inline&quot;);</pre>
<p>&nbsp;</p>
<p>The opposite, take an inline element (e.g. &lt;strong&gt;) and make it take up a whole line:</p>
<p>&nbsp;</p>
<pre name="code" class="javascript">
 $(&quot;#example&quot;).css(&quot;display&quot;,&quot;block&quot;);</pre>
<p>&nbsp;</p>
<p>That&#8217;ll get someone&#8217;s attention!</p>
<p>Far too often, a jQuery developer will find themselves poking and prodding a bit of jQuery code, trying to get it to behave properly; when their answer is just a css() command away.</p>
<p>This is not to say that you have to choose between Javascript or jQuery, though.&nbsp; By combining the two, we can still use jQuery for what it&#8217;s best at: selecting elements and manipulating their attributes.&nbsp; For example, instead of using the whole line of document.getElementById(&quot;element&quot;) we can save ourselves some code by using $(&quot;#element&quot;).&nbsp; jQuery has a built-in checker for elements selected by that and will essentially translate it to our full &quot;getElementById&quot; line, anyhow, so we are literally just using it to abbreviate our code.</p>
<p>This is just the tip of the iceberg.&nbsp; Technically speaking, jQuery is a collection of snippets that allow someone to abide by the D.R.Y. (Don&#8217;t Repeat Yourself) method of programming.&nbsp; I urge you, however, to take advantage of jQuery, but not completely depend on it to code.</p>
<p>jQuery is a tool.&nbsp; Javascript is the garden.&nbsp; Together, they can allow us to cultivate endless abundance if utilized in harmony.</p>
<p>Knowing jQuery (among many other scripting libraries) in this modern world of web development is crucial.&nbsp; It provides quicker turn around times, opens your code up to a vast world of other developers and makes your code efficient, and easy to read.&nbsp; However, even the best tools are only as useful as the person who wields them.</p>
<p>If we have not only a better understanding of our tools, but also our environment, then we can help usher in &#8212; if not pioneer &#8212; the next era of web developers.</p>
<p>&nbsp;</p>
<p><span style="font-size: x-large;"><strong>Thoughts from:</strong></span><strong></p>
<p><span style="font-size: large;">David Walsh</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</p>
<p><img width="200" vspace="10" hspace="10" height="200" align="left" style="padding: 10px;" alt="" src="http://addyosmani.com/blog/wp-content/uploads/david.jpg" /></p>
<p>&quot;Learning JavaScript is absolutely paramount to becoming an effective Web Designer or Developer.&nbsp; While the JavaScript libraries do as much as possible to ease the pain of some of JavaScript&#8217;s more time-consuming tasks, libraries cannot anticipate their every use.&nbsp; Without proper knowledge of JavaScript, a developer can spend hours debugging an issue that should really only take a few moments.&nbsp; Spending the time to become a &#8216;Vanilla JS&#8217; expert will allow a developer to more easily learn *any* of the popular frameworks, thus making that developer far more valuable.&quot;</p>
<p>&nbsp;</p>
<p><span style="font-size: large;"><strong>Chris Coyier</strong></span></p>
<p><img width="200" vspace="10" hspace="10" height="200" align="left" style="padding: 10px;" alt="" src="http://addyosmani.com/blog/wp-content/uploads/chris.jpg" /></p>
<p>&quot;I&#8217;d love to tell you all about how life will be better if you learn and understand JavaScript before you learn libraries. Or at least, that you should go back and get those fundamentals after starting out with libraries. Here is reality for me though: I&#8217;m terrible at vanilla JavaScript. It would be pretty hard for me to try and get day-to-day design work done if I couldn&#8217;t use jQuery. In fact, I probably just wouldn&#8217;t do it, and stick to design and markup. I&#8217;d love to go back and get those fundamentals, and I probably will over time, and it will make me better, but I&#8217;m also living proof that you can still get the job done being a library junkie.&quot;<span style="font-size: large;"><br />
</span></p>
<p>&nbsp;</p>
<p>&nbsp;<span style="font-size: large;"><strong>Janko Javanovic</strong></span></p>
<p><img width="200" vspace="10" hspace="10" height="200" align="left" style="padding: 10px;" alt="" src="http://addyosmani.com/blog/wp-content/uploads/janko.jpg" />&quot;I will be glad to give an opinion about js/jQuery. I agree that developers should have at least some understanding of JavaScript. jQuery and similar libraries might be a good way to get people interested in JavaScript in general. But in the other hand it might actually be a stumbling block &#8211; it&#8217;s so easy to use jQuery that many don&#8217;t need a deeper understanding of JS.</p>
<p>Lack of knowledge become obvious when developers need to modify/extend some jQuery code. They don&#8217;t understand it fully. And then they cry for help. So I&#8217;d say it would be better for them to learn a few things about JS and try figure things out themselves. Otherwise, chances are they will never learn.&quot;</p>
<p><span style="font-size: large;"><strong>Marco Kuiper</strong></span></p>
<p><img width="200" vspace="10" hspace="10" height="200" align="left" style="padding: 10px;" alt="" src="http://addyosmani.com/blog/wp-content/uploads/marco.jpg" /></p>
<p>&quot;Very interesting topic, especially since I learned jQuery before learning actual JavaScript myself (the only JavaScript I knew before that were the &quot;mouse following clock&quot; and &quot;disable right click&quot; stuff &#8211; you know, back in the days&#8230;). But at the time I started to get a hang of jQuery, I did wanted to learn more about JavaScript. Why? Basically because I wanted to get the maximum out of jQuery.</p>
<p>For example, take a look at speed. I learned that using an ID selector ( $(&quot;#myelement&quot;) ) is around 100 times faster than a class selector ( $(&quot;.myelement&quot;) ) . This is because the ID selector maps to the native &quot;getElementByID()&quot; JavaScript function. The same is for using tag selectors ( $(&quot;body&quot;) ), since that maps to the native &quot;getElementsByTagName()&quot; JavaScript function. The class selector loops through all the objects in the DOM to find the specified elements. There are more speed tricks for jQuery that you would know if you knew how JavaScript works.</p>
<p>I truly love the way how you can create elements in jQuery 1.4; Simply apply an element name to the jQuery core method and you&#8217;re ready to go ( $(&quot;&lt;div /&gt;&quot;) ). Before that way was implemented in jQuery, you could simply use the native JavaScript method &quot;document.createElement()&quot;. Although it isn&#8217;t as great as the way jQuery creates elements, it did allow you to create elements using JavaScript. Using those kind of methods even before it was added to the jQuery core, and you were sure to be one step ahead of the rest.</p>
<p>The last example I want to show you, is the use of parameters. The jQuery &quot;.bind()&quot; method attaches behavior to a specified element. The first parameter is the eventType, like &quot;click&quot;, &quot;mouseenter&quot; and &quot;mouseleave&quot;. How would you know which eventTypes you could specify, if you don&#8217;t know the implementation of JavaScript (&quot;object.onmouseenter&quot; etc.)? And why do you use all those curly brackets (when creating objects) and using functions as parameters ( $(&quot;#myelement&quot;).click(function() { var doStuff; } ); )? All that kind of stuff is JavaScript that you&#8217;re using. If you&#8217;re using it, use it and learn it correct.</p>
<p>So, if you want to get better at jQuery, take a look &quot;under the hood&quot; to see the JavaScript engine that is working hard for you. Learn and master it!&quot;</p>
<p>&nbsp;</p>
<p><span style="font-size: large;"><strong>James Padolsey</strong></span></p>
<p><img width="200" vspace="10" hspace="10" height="200" align="left" style="padding: 10px;" alt="" src="http://addyosmani.com/blog/wp-content/uploads/james.jpg" /></p>
<p>&quot;I agree that there is a problem with the terminology used throughout the jQuery community. jQuery uniquely appeals to people with minimal programming experience and that makes it all the more complicated to explain it in the right way. I&rsquo;ve always been a proponent of learning JavaScript and the DOM API before any library. I&rsquo;m not saying that this is the only way; obviously there are people who have learnt it the other way round, and they&rsquo;re just as proficient as you or I. But, still, there is a difficulty to overcome, and I think there&rsquo;s a lot of progress that needs to be made in the way that jQuery&rsquo;s paradigms and implementation are explained to beginners. I think you&rsquo;re right about &ldquo;wrapping&rdquo; being misleading, but, it is a helpful metaphor which gives beginners confidence when using jQuery.</p>
<p>Let&rsquo;s face it! Most people that use jQuery are not looking to become an expert. They don&rsquo;t care about its internals or what really happens when they call the magical dollar. They just want it to work. The people who really want to dig into it will do so by their own means.</p>
<p>I&rsquo;ve used some of these metaphors myself, such as &ldquo;caching&rdquo; &mdash; it can be misleading but most &ldquo;web&rdquo; people understand the term. If I said &ldquo;reference&rdquo; instead then I&rsquo;d have to explain what a reference is and how objects in JavaScript are different to primitive types, and how an identifier is simply a pointer to an object in &ldquo;memory&rdquo;&hellip; it gets complicated very quickly.</p>
<p>jQuery is one of those cool technologies that gives you tremendous power right off the bat! That&rsquo;s what appeals to beginners, I think. They feel powerful; they feel that they pretty-much understand jQuery and how it works. We wouldn&rsquo;t want to shatter that confidence by the realisation that they, in fact, still have a lot to learn about jQuery, JavaScript, and the DOM.</p>
<p>Don&rsquo;t get me wrong. I really do support the idea that beginners should be taught correctly right from square one, but I think it needs to be done delicately. You can&rsquo;t drown them with complicated words and ideas; that&rsquo;ll surely scare them away.&quot;</p>
<p>I would say that learning APIs and abstractions such as the DOM, jQuery, Mootools, Prototype, Dojo, ExtJS and others is quite pointless for the beginner because there are literally thousands of libraries, toolkits and frameworks that the beginner _could_ pick up&#8230;. Obviously the DOM is central but at the end of the day it&#8217;s just a bunch of method-names and argument signatures that you have to remember.</p>
<p>What needs to be taught is **JavaScript** &#8230; or rather, ECMAScript.. the real thing &#8212; i.e. hand out a copy of the ES3 specification. (actually, that&#8217;d definitely scare people)</p>
<p>The problem with learning JS is that most of the really good resources are simply not geared towards beginners. Websites like w3schools and &quot;javascript.about.com&quot; ARE geared towards beginners but their content is crap &#8212; it&#8217;ll get an individual past the noob phase but not any further. They need to be learning about primitives, objects, variable declaration, function declaration, function expressions, scope, closure, operator precedence, booleans&#8230; blah blah blah&#8230; The rhino book is what they all really need.</p>
<p>Most of the people using jQuery don&#8217;t even want to &quot;program&quot;, per se; they just want to add cool&#8217;ness to their websites. Telling them they defined a global instead of a local var, and they should probably use function declarations because it makes debugging easier is pointless because they really couldn&#8217;t care less. The devs that really care about code quality and all the stuff we love are already on the path to enlightenment.&quot;</p>
<p>&nbsp;</p>
<p><strong><span style="font-size: large;">Conclusions</span></strong></p>
<p>And that&#8217;s it guys. What are your thoughts on the topic?. Do <em>you</em> think that it&#8217;s important to have an understanding of basic JavaScript?. We&#8217;d all love to have an open discussion on this and we&#8217;d really like to hear your opinions in the comments section below.  If you liked the post, remember that you can easily share it with your friends and colleagues just be clicking the <a class="retweet" href="http://addyosmani.com/blog/javascriptuncovered/">jQuery Vs. JavaScript &#8211; The Masters Share Their Views On Vanilla JS</a> button. I hope you found this post useful guys!</p>
<p>.</p>
]]></content:encoded>
			<wfw:commentRss>http://addyosmani.com/blog/javascriptuncovered/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
		<item>
		<title>8 jQuery Performance &amp; Optimization Tips You Need In 2010</title>
		<link>http://addyosmani.com/blog/8-jquery-performance-tips/</link>
		<comments>http://addyosmani.com/blog/8-jquery-performance-tips/#comments</comments>
		<pubDate>Sat, 01 May 2010 10:50:00 +0000</pubDate>
		<dc:creator>Addy</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[jquery performance optimization optimal junit fireunit jquery unit testing root selectors optimizing benchmarking]]></category>

		<guid isPermaLink="false">http://addyosmani.com/blog/8-jquery-performance-optimization-tips-you-need-in-2010/</guid>
		<description><![CDATA[&#160; Great topic today!. Performance optimization. Performance optimization is an important aspect of any type of coding project, including those that use jQuery. Today I&#8217;m going to go through some quick useful jQuery coding and performance tips that I think are important for every JavaScript developer to bare in mind when writing their projects using [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://addyosmani.com/blog/8-jquery-performance-tips/"><img width="530" height="342" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/04/per.jpg" alt="per" style="border: 0px none; display: inline;" title="per" /></a></p>
<p>&nbsp;</p>
<p>Great topic today!. Performance optimization. Performance optimization is an important aspect of any type of coding project, including those that use jQuery. Today I&#8217;m going to go through some quick useful jQuery coding and performance tips that I think are important for every JavaScript developer to bare in mind when writing their projects using the jQuery framework. Some of these are going to be a little obvious whilst others are things that you might not have considered doing before.</p>
<p><span id="more-717"></span></p>
<p>Ask yourself this question. Do you think that your scripts are currently running as quickly as they could be?. Do they occupy the smallest filesize footprint and still deliver the same results as their un-optimized counterparts?. The answer to these questions in most cases is &lsquo;no&rsquo;.</p>
<p>Often in web development we&rsquo;re working against tight deadlines and can sometimes fall into a pattern of thinking that if our scripts work in all web browsers and aren&rsquo;t howling alert! help me! that our job is done. The truth is that if we were to all put in just a little bit more effort, we could actually deliver web applications and scripts that are both fully functional and as optimal as they can be.</p>
<p>Today I&rsquo;m going to give you 8 tips that will help you ensure that your jQuery projects stay optimized.</p>
<p><strong></p>
<h2>1. Stay up to date! Are you using methods and techniques that are obsolete?.</h2>
<p></strong></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://addyosmani.com/blog/wp-content/uploads/2010/04/image9.png" class="thickbox"><img width="384" height="294" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/04/image_thumb8.png" alt="image" style="border-width: 0px; display: inline;" title="image" /></a></p>
<p>When I say obsolete, I mean that there may be better ways to achieving code that you regularly write. The easiest way to find out if this is the case is to ask yourself this question:&nbsp; Do you know what the differences between jQuery 1.3.2 and jQuery 1.4.2 are?. If not, keep reading!</p>
<p>The jQuery team spend hundreds of combined hours every year churning out new functions and optimizing the existing ones in the jQuery library. Heck, I sometimes question if John Resig even sleeps, such is his dedication to making the library be as efficient as possible.</p>
<p>What this means is that if you&#8217;re able to use the latest features and techniques jQuery has to offer that are more optimal that what you&#8217;ve been using so far, you can get very cheap, very quick boosts in performance for your application.</p>
<p>We all know that it can be a lot easier just using the jQuery techniques you&rsquo;re already used to, but if it just takes a few minutes to read through the specs and pick up a few quick performance wins, then why not just do it?</p>
<p>Do you know what all of these do?</p>
<p>
Delegate/Undelegate<br />
nextUntil<br />
Chaining event handlers<br />
Controlling a functions context<br />
Does a element have something? (.has)<br />
Element Unwrapping<br />
Determining an object&#8217;s type</p>
<p>If not, here are the tutorials and references for the jQuery:</p>
<ul>
<li><strong>1.4</strong> features: <a href="http://net.tutsplus.com/tutorials/javascript-ajax/jquery-1-4-released-the-15-new-features-you-must-know/">http://net.tutsplus.com/tutorials/javascript-ajax/jquery-1-4-released-the-15-new-features-you-must-know/</a></li>
<li><strong>1.4.1</strong> features: <a href="http://api.jquery.com/category/version/1.4.1/">http://api.jquery.com/category/version/1.4.1/</a></li>
<li><strong>1.4.2</strong> core features: <a href="http://www.learningjquery.com/2010/03/using-delegate-and-undelegate-in-jquery-1-4-2">http://www.learningjquery.com/2010/03/using-delegate-and-undelegate-in-jquery-1-4-2</a> and&nbsp; <a href="http://api.jquery.com/category/version/1.4.2/">http://api.jquery.com/category/version/1.4.2/</a></li>
</ul>
<p>you can also find tons of 1.4.2 snippets in my recent jQuery <a href="http://addyosmani.com/blog/?s=snippets">snippet posts</a>.</p>
<p>&nbsp;</p>
<p><strong></p>
<h2>2. Context-aware jQuery Code Execution &ndash; Are you loading code that isn&rsquo;t needed?</h2>
<p></strong></p>
<p>&nbsp;</p>
<p>There are some developers that will load all of the jQuery code for a site on every page, regardless of whether or not it&rsquo;s going to be used there or not. (Don&rsquo;t worry, if you&rsquo;ve done this before, the good news is you can always change that habit!).</p>
<p>What you need to remember is that jQuery still has to take time to execute that code and if its not needed you can get a quick performance gain by checking whether you&#8217;re on a page which requires that script to run.</p>
<p>This can be achieved in many ways such as defining a class or ID unique to each page&rsquo;s content and checking for it&#8217;s existence before you run it&#8217;s specific code or even through server-side processing if you want to run check on the filename being accessed.</p>
<p>As long as you can do your best to only load code that&rsquo;s needed, you&rsquo;ll get some quick performance boosts that may not have been there if you hadn&rsquo;t thought about this in advance.</p>
<p>&nbsp;</p>
<p><strong></p>
<h2>3. jQuery Unit Testing</h2>
<p></strong></p>
<p>&nbsp;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://addyosmani.com/blog/wp-content/uploads/2010/04/image10.png" class="thickbox"><img width="436" height="241" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/04/image_thumb9.png" alt="image" style="border-width: 0px; display: inline;" title="image" /></a></p>
<p>
How many of you have actually written unit tests for your JavaScript or jQuery code this week?. I&#8217;m hearing crickets and one man in the corner saying &lsquo;me&rsquo;. Uh oh. I think that there&#8217;s a tendency for us web developers to&nbsp; forget that just like Java, C++ or .NET, JavaScript is a programming language equally as capable of having bugs as the others and to minimize this, spend just that extra little bit of time on your project writing some unit tests for your code. It&rsquo;s really really easy to.</p>
<p>Not only is it good as a software engineering best practice, but it&rsquo;s also something you need if your code is going into a live production system which could be accessed by a large audience. You want your code to be fully functional and to be structured in such a way that you know exactly how it&rsquo;s going to behave and can anticipate quirks in advance.</p>
<p>One right off the top of my head is if you&rsquo;re using Ajax to load up some of your page content. If things are taking a longer to load up than they should, wouldn&rsquo;t it be nicer if your app output a &lsquo;Connection Issue Detected, please try refreshing&rsquo; message rather than just hanging for ages?. Believe me, your users will appreciate your attention to detail.</p>
<p>If you&#8217;re looking for some powerful JavaScript unit testing tools, QUnit and FireUnit are both quite useful and I&#8217;d recommend checking them out. Nettuts also put out a really straightforward <a href="http://net.tutsplus.com/tutorials/javascript-ajax/how-to-test-your-javascript-code-with-qunit/">article</a> last year on how to use QUnit to test your jQuery code and I&rsquo;d recommend giving it a read some time.</p>
<p><strong></p>
<h2>4. Benchmark Your jQuery Code</h2>
<p></strong></p>
<p>&nbsp;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://addyosmani.com/blog/wp-content/uploads/2010/04/image11.png" class="thickbox"><img width="370" height="284" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/04/image_thumb10.png" alt="image" style="border-width: 0px; display: inline;" title="image" /></a></p>
<p>How fast is your code? If you&rsquo;re looking for a simple way to improve the performance of your code, simply log the amount of time it takes for your functions to execute and use that as a starting point for your optimization strategy.</p>
<p>The Firebug console makes it very easy for any JavaScript developer to log debug information in the same way you would with any other language&rsquo;s IDE so consider using it. Logging might sound very simple, but it can actually turn up quirks in your code you may not have realized existed or which may need optimization.</p>
<p>Now if you&rsquo;re looking for even more accurate results (remember, Firebug is an add-on and will introduce marginal delays to your stats because it&rsquo;s GUI needs to be updated dynamically), close Firebug and create your own own simple logging tool as follows (note: this is a very basic example and you&rsquo;ll need to edit the code as per your needs).</p>
<p>JavaScript</p>
<pre class="javascript" name="code">
function t() {
    var time = new Date();
    return time.getTime();
} 

$(window).load(function() {
    var s = t(); 

    for (var i=0; i&lt;10000; i=i+1) {
        $('#content').html(&quot;hello&quot;);
    }
    $('#out').append( (t()-s) +'ms');
});
</pre>
<p>HTML</p>
<pre class="html" name="code">
<div>Time:</div>
<div>Content:</div>
</pre>
<p>Benchmarking ensures that you know how fast your code runs, not just in one browser but potentially in all of them. This can be of significant importance when you&rsquo;re talking about large jQuery applications or apps that rely heavily on JavaScript based animations or Ajax.</p>
<p>&nbsp;</p>
<p><strong></p>
<h2>5. Keep download times to a minimum with one compressed master JS file.</h2>
<p></strong></p>
<p>&nbsp;&nbsp;&nbsp; <a href="http://addyosmani.com/blog/wp-content/uploads/2010/04/image12.png" class="thickbox"><img width="446" height="295" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/04/image_thumb11.png" alt="image" style="border-width: 0px; display: inline;" title="image" /></a></p>
<p>Page-load speeds are an ever increasingly important factor in performance optimization and one only needs to look at Google&rsquo;s inclusion of this in page rankings to realize just how important decreasing the number of files you need to load is.</p>
<p>How many WordPress, Corporate or Portfolio sites to you visit where if you look at the source code, you&#8217;ll see maybe 10 or 12 different JavaScript files that need to be loaded before the page is ready to be used?. If you want your pages to load quicker, just ensure that you use a compression and concatenation tool that will put all your scripts into the same file so you can still update them separately but they&#8217;ll be delivered at the same time on your live site. This way you&#8217;ll achieve both a smaller JavaScript footprint<br />
and your site only requiring one JS file to download for your code.</p>
<p>(A sidenote with that is, please try to cut down on the number of document.ready and window.load instances in your page. If your code will all be running out of the same file, it probably makes sense to just have one instance of these running).</p>
<p>These resources will help you achieve all of the above and are free whether<br />
you are using a PC or Mac:</p>
<p><a href="http://jscompress.com/">http://jscompress.com/</a> (for any sites)<br />
<a href="http://www.halmatferello.com/lab/wp-js/">http://www.halmatferello.com/lab/wp-js/</a> (for WordPress users)<br />
<a href="http://ant.apache.org/manual/CoreTasks/concat.html">http://ant.apache.org/manual/CoreTasks/concat.html</a> (for Ant users)&nbsp;&nbsp;</p>
<p><strong></p>
<h2>6. Context Vs. Find</h2>
<p></strong></p>
<p>&nbsp;</p>
<p>It&rsquo;s true, where possible you should always try to run your selections based on a context however it&rsquo;s useful just to bare in mind that when you&rsquo;re passing a context to the jQuery constructor, it creates an extra unnecessary extra function call.</p>
<p>jQuery&rsquo;s insides run content.find(selector) anyway, so you can technically skip that step if you&rsquo;re working in a page structure that may not benefit greatly from using context. Below you can see an example of what I&rsquo;m talking about.</p>
<pre class="javascript" name="code">
//This is context is typically used.
$('div', context ).doSomethingOrOther();

//But here, you can do the same thing minus the extra
//instance and the additional function call
context.find('div').doSomethingOrOther();
</pre>
<p><strong></p>
<h2>7. Window.load all the way.</h2>
<p></strong></p>
<p>&nbsp;</p>
<p>Document.ready isn&rsquo;t a terrible thing, but it&#8217;s a habit that many developers still have including myself occasionally. It doesn&#8217;t matter where you&#8217;re using $(function(){}); or the full version of this, but truth be told it is significantly more optimal to be using Window.load in your applications.</p>
<p>The reason behind this idea is that document.ready happens during page render while&nbsp; objects are still downloading and that cause some stalls in your page. You don&rsquo;t want that. You can however reduce the CPU utilization during the page load by binding your jQuery functions to&nbsp; the $(window).load event &#8211; it occurs after all objects called by the HTML have fully completed downloading.</p>
<p>That&rsquo;s one line change that can give you scripts that little extra performance boost!.</p>
<p><strong> </strong></p>
<h2><strong>8.</strong> <strong>Strike A Balance Between Your Use Of JavaScript &amp; jQuery</strong></h2>
<p>&nbsp;</p>
<p>jQuery is a fantastic way to speed up work for almost anyone on the front-end. Remember however, that there are scenarios where jQuery may take longer to execute certain functions than if you were to use regular JavaScript. CSS styling is just one example that comes to mind.</p>
<p>Some of the other methods we&#8217;re all used to using like show() and hide() also have their own performance overheads so always remember to strike a balance between your code&#8217;s complexity and it&#8217;s overall efficiency. You can always mix plain JavaScript code with some jQuery and in most cases it should still run fine.</p>
<p>Another situation is this: If all you need to do is run two lines of JavaScript code, there isn&#8217;t a need for you to use jQuery (even in it&#8217;s minified form it&#8217;s still roughly 20-30kb&#8217;s worth of extra data that needs to be downloaded).&nbsp; Similarly, if you&#8217;re writing a large complex application try to use jQuery rather than writing overly long plain-JavaScript script.</p>
<p>Use best judgement here and you&#8217;ll find that you&#8217;ll get the both of both worlds and their combined performance advantages.</p>
<p>&nbsp;</p>
<p><strong>And that&rsquo;s it!. If you&rsquo;ve found this post useful please feel free to share it with your friends and colleagues by clicking the <a href="http://addyosmani.com/blog/8-jquery-performance-tips/" class="retweet">8 jQuery Performance &amp; Optimization Tips You Need</a> button. Until next time, may the $ be with you.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://addyosmani.com/blog/8-jquery-performance-tips/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>ShineTime &#8211; A Kick-Ass New jQuery &amp; CSS3 Gallery With Animated Shine Effects</title>
		<link>http://addyosmani.com/blog/shinetime/</link>
		<comments>http://addyosmani.com/blog/shinetime/#comments</comments>
		<pubDate>Sun, 18 Apr 2010 22:30:00 +0000</pubDate>
		<dc:creator>Addy</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[jquery image gallery carousel pictures photos images shine shinetime gloss animation animated javascript glossy detailed design]]></category>

		<guid isPermaLink="false">http://addyosmani.com/blog/shinetime-a-kick-ass-new-jquery-css3-gallery-with-animated-shine-effects/</guid>
		<description><![CDATA[&#160; This week I&#8217;d like to show you how you can create a kick-ass animated Shine Effect with jQuery &#38; CSS3 and then use it to create your very own Shiny Gallery &#8216;ShineTime&#8217;. This effect is useful in making your user interface elements look like they&#8217;re a real polaroid photo (or made of glass)&#160; and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://addyosmani.com/blog/shinetime/"><img width="530" height="342" border="0" title="jkick" style="border: 0px none; display: inline;" alt="jkick" src="http://addyosmani.com/blog/wp-content/uploads/2010/04/jkick.jpg" /></a></p>
<p>&nbsp;</p>
<p>
This week I&rsquo;d like to show you how you can create a kick-ass animated Shine Effect with jQuery &amp; CSS3 and then use it to create your very own Shiny Gallery &lsquo;ShineTime&rsquo;. This effect is useful in making your user interface elements look like they&rsquo;re a real polaroid photo (or made of glass)&nbsp; and the best part is, it&rsquo;s not that difficult to achieve. I always think it&rsquo;s useful to see a demo of what we&rsquo;re making before we look at it, so click here to check out the live <a href="http://www.addyosmani.com/resources/shinetime"><strong>demo</strong></a>.&nbsp; <a href="http://addyosmani.com/blog/wp-content/uploads/2010/04/image2.png" class="thickbox"><img width="198" height="15" border="0" title="image" style="border: 0px none; display: inline;" alt="image" src="http://addyosmani.com/blog/wp-content/uploads/2010/04/image_thumb2.png" /></a>&nbsp;</p>
<p>You&rsquo;ll also learn today how you can successfully use layering in your designs to give your gallery that extra bit of detail that can make it stand out from the others. Whilst I&rsquo;m going to leave it to David Walsh to provide you with galleries full of Christina Ricci photos, today&rsquo;s component includes a set of pictures from the movie &lsquo;Kick-Ass&rsquo; for no other reason than because ; )</p>
<p><span id="more-702"></span></p>
<p>&nbsp;</p>
<p><a href="http://addyosmani.com/blog/wp-content/uploads/2010/04/image3.png" class="thickbox"><img width="507" height="323" border="0" title="image" style="border: 0px none; display: block; float: none; margin-left: auto; margin-right: auto;" alt="image" src="http://addyosmani.com/blog/wp-content/uploads/2010/04/image3.png" /></a></p>
<p><a href="http://addyosmani.com/blog/wp-content/uploads/2010/04/image4.png" class="thickbox"><img width="243" height="157" border="0" title="image" style="border: 0px none; display: inline;" alt="image" src="http://addyosmani.com/blog/wp-content/uploads/2010/04/image_thumb3.png" /></a>&nbsp;&nbsp; <a href="http://addyosmani.com/blog/wp-content/uploads/2010/04/image5.png" class="thickbox"><img width="239" height="155" border="0" title="image" style="border: 0px none; display: inline;" alt="image" src="http://addyosmani.com/blog/wp-content/uploads/2010/04/image_thumb4.png" /></a></p>
<p><strong>The Animated &lsquo;Shine&rsquo; Effect</strong></p>
<p>The idea behind a Shine Effect is to give your graphics the appearance of being on a glossy surface that have just had a light beam pass over them. This can make them appear to be made of glass and can increase the visual experience your end users see.</p>
<p>Before we get into any code, lets go through the basic concepts behind the effect. We want to pass a light-beam (in this case an image simulating a shine) past our image when the user hovers over it. Now because I wanted to style up today&rsquo;s gallery so that each thumbnail appeared to float out of it&rsquo;s container, the steps to achieving the below animation are as follows:</p>
<ol>
<li>Change the margins of the thumbnail element so that it floats away from it&rsquo;s container</li>
<li>Set the background-position of your &ldquo;shine&rdquo; graphic to be &ndash;1 * (it&rsquo;s total width)</li>
<li>Animate your background-position to value of the total width. Effectively we&rsquo;re hiding the gloss off-stage and then animating it across the image.</li>
</ol>
<p>You can see this being achieved in the diagram below.</p>
<p><a href="http://addyosmani.com/blog/wp-content/uploads/2010/04/image6.png" class="thickbox"><img width="483" height="248" border="0" title="image" style="border: 0px none; display: block; float: none; margin-left: auto; margin-right: auto;" alt="image" src="http://addyosmani.com/blog/wp-content/uploads/2010/04/image_thumb5.png" /></a></p>
<p>Now, because ShineTime is going to also apply this effect to the caption holder component (see the demo), I needed to come up with a much larger shine graphic for this that cleanly executes the desired effect without being slow or making the text unreadable. Using an image about 20% longer than the container in each direction at a layer below the text made this possible.</p>
<p><a href="http://addyosmani.com/blog/wp-content/uploads/2010/04/image7.png" class="thickbox"><img width="486" height="255" border="0" title="image" style="border: 0px none; display: block; float: none; margin-left: auto; margin-right: auto;" alt="image" src="http://addyosmani.com/blog/wp-content/uploads/2010/04/image_thumb6.png" /></a></p>
<p><strong>Designing ShineTime</strong></p>
<p>Graphics-wise, there are a few important things to note about ShineTime. I wanted to give this demo an extra-depth of design detail so the following techniques were applied to create the final main-photo area:</p>
<ol>
<li><strong>CSS3</strong> is used to create the rounded-corner borders around the main container div. It is also used on the indented shadow layer (which you can see below). In order for the caption container to also fit this design spec, it&rsquo;s bottom rounded corners use CSS3 to keep everything looking like it&rsquo;s inside the same box.</li>
<li>Layering is heavily used in this demo to achieve a photographic-depth effect. The choice to do this using an image rather than CSS3 was in order to preserve the effect displaying in browsers like IE6.</li>
<li>Normally, image galleries are based on UL/LI elements which are wrapped together using jQuery &amp; CSS to turn them into something pretty. Here, because the actual image needs to be behind a few other layers so that it can have (a) Rounded corners and (b) the photo-effect, it&rsquo;s necessary for all images to be loaded using the background-image property of the &lsquo;largephoto&rsquo; div (take a look at the HTML code to see what I&rsquo;m talking about)</li>
<li>CSS3 is finally also used on the ShineTime Header. Whilst I&rsquo;ve included Cufon for a little added cleanliness to my typographic elements, in the header it&rsquo;s simply used for adding an indented feel to the text to give the background that extra &lsquo;metallic&rsquo; feel to it.</li>
</ol>
<p><a href="http://addyosmani.com/blog/wp-content/uploads/2010/04/image8.png" class="thickbox"><img width="451" height="401" border="0" title="image" style="border: 0px none; display: block; float: none; margin-left: auto; margin-right: auto;" alt="image" src="http://addyosmani.com/blog/wp-content/uploads/2010/04/image_thumb7.png" /></a></p>
<p><strong>The Code</strong></p>
<p>Finally, for the part you&rsquo;ve been waiting for: the code.</p>
<p><strong>HTML (Sample)</strong></p>
<pre class="html" name="code"><!-- Each entry takes the form -->
<!-- start entry-->
<div class="thumbnailimage">
<div class="thumb_container"> 
<div class="large_thumb"> <img alt="thumb" class="large_thumb_image" src="images/thumbnails/sample1.jpg" />   <img rel="Just because I can't code,
doesn't mean I can't kick your ass!" class="large_image" src="images/large/sample1.jpg" alt="" />
<div class="large_thumb_border">&nbsp;</div>
<div class="large_thumb_shine">&nbsp;</div>
</div>
</div>
</div>

       <!--end entry-->       

<!-- whilst the main image container itself looks like-->
<div id="containertitle">Welcome to ShineTime</div>
<div class="mainframe">
<div id="largephoto">
<div id="loader">&nbsp;</div>
<div id="largecaption">
<div class="captionShine">&nbsp;</div>
<div class="captionContent">&nbsp;</div>
</div>
<div id="largetrans">&nbsp;</div>
</div>
</div>
</pre>
<p>&nbsp;</p>
<p><strong>CSS</strong></p>
<pre class="css" name="code">
body { background-color:#333; margin:0 auto;
background-image:url('images/interface/bgnoise.png');}
#container { width:793px; height:498px; margin:0 auto;
background-image:url('images/interface/back_noise.png');
background-color:#111; margin-top:40px;}
#container .mainframe { width: 500px; height:498px; float:left}
#container .thumbnails { float:left; width:293px; height:498px;
background-repeat:no-repeat; background-image:url('images/interface/total_grid.png');
background-position:9px 70px; }
.thumbnailimage { float:left; padding:7px;}
.large_thumb	{float:left; position: relative; width:64px;
height:64px; padding:0px 10px 0px 0;}
img.large_thumb_image	{position:absolute; left:5px; top:4px;}
.large_thumb_border	{width:64px; height:64px;
background:url('images/interface/thumb_border.png'); position:absolute; }
.large_thumb_shine	{width:54px; height:54px;
background:url('images/interface/shine.png'); position:absolute;
background-position:-150px 0; left:5px; top:4px; background-repeat:no-repeat;}
.thumb_container { width:64px; height:64px;
background-image:url('images/interface/thumb_holder.png'); }
#largephoto { width: 444px; height:370px; background-color:#333333;
margin-top:68px; margin-left:40px; -moz-border-radius: 10px;
-webkit-border-radius: 10px; border-left: 1px solid #fff;
border-right: 1px solid #fff; border-bottom: 1px solid #fff; }
#largetrans { width: 444px; height:370px;
background-image:url('images/interface/main_bg_trans.png');
-moz-border-radius: 10px; -webkit-border-radius: 10px;}
.large_image { display:none}
#containertitle { position:absolute; margin-top:35px;
margin-left:40px; font-family:Arial, Helvetica, sans-serif;
font-weight:bold; text-shadow: 0px 1px 2px #fff;}
#largecaption {  text-align:center; height:100px;
width:100%; background-color:#111; position:absolute; width: 444px;
margin-top:270px; -moz-border-radius-bottomleft: 10px;
-moz-border-radius-bottomright: 10px; -webkit-border-bottom-left-radius: 10px;
-webkit-border-bottom-right-radius: 10px;
display:none; color:#fff; font-size:30px;
font-family:Arial; letter-spacing:-1px; font-weight:bold}
#largecaption .captionContent { padding:5px;}
#largecaption .captionShine { background:url('images/interface/bigshine.png');
 position:absolute;  width: 444px; height: 100px;
 background-position:-150px 0;background-repeat:no-repeat;}
#loader { width:150px; height:150px;
background-image:url('images/interface/loader.gif');
background-repeat:no-repeat; position:absolute;}
</pre>
<p>&nbsp;</p>
<p><strong>JavaScript</strong>&nbsp;</p>
<pre class="javascript" name="code">
 $(document).ready(function()
  {

	 /*Your ShineTime Welcome Image*/
	 var default_image = 'images/large/default.jpg';
	 var default_caption = 'Welcome to ShineTime';

	 /*Load The Default Image*/
	 loadPhoto(default_image, default_caption);

	 function loadPhoto($url, $caption)
	 {

	    /*Image pre-loader*/
	    showPreloader();
	    var img = new Image();
	    jQuery(img).load( function()
		{
			jQuery(img).hide();
			hidePreloader();

        }).attr({ &quot;src&quot;: $url });

	    $('#largephoto').css('background-image','url(&quot;' + $url + '&quot;)');
		$('#largephoto').data('caption', $caption);
	 }

	 /* When a thumbnail is clicked*/
	 $('.thumb_container').click(function()
	 {

		  var handler = $(this).find('.large_image');
		  var newsrc  = handler.attr('src');
		  var newcaption  = handler.attr('rel');
		  loadPhoto(newsrc, newcaption);

	 });

	 /*When the main photo is hovered over*/
	 $('#largephoto').hover(function()
	 {

		var currentCaption  = ($(this).data('caption'));
		var largeCaption = $(this).find('#largecaption');

		largeCaption.stop();
		largeCaption.css('opacity','0.9');
		largeCaption.find('.captionContent').html(currentCaption);
		largeCaption.fadeIn()

		 largeCaption.find('.captionShine').stop();
         largeCaption.find('.captionShine').css(&quot;background-position&quot;,&quot;-550px 0&quot;);
         largeCaption.find('.captionShine').animate({backgroundPosition: '550px 0'},700);

		 Cufon.replace('.captionContent');

	 },

	 function()
	 {
	    var largeCaption = $(this).find('#largecaption');
		largeCaption.find('.captionContent').html('');
		largeCaption.fadeOut();

	 });

     /* When a thumbnail is hovered over*/
	 $('.thumb_container').hover(function()
	 {
         $(this).find(&quot;.large_thumb&quot;).stop().animate({marginLeft:-7, marginTop:-7},200);
		 $(this).find(&quot;.large_thumb_shine&quot;).stop();
         $(this).find(&quot;.large_thumb_shine&quot;).css(&quot;background-position&quot;,&quot;-99px 0&quot;);
         $(this).find(&quot;.large_thumb_shine&quot;).animate({backgroundPosition: '99px 0'},700);

	 }, function()
	 {
	    $(this).find(&quot;.large_thumb&quot;).stop().animate({marginLeft:0, marginTop:0},200);
	 });

	 function showPreloader()
	 {
	   $('#loader').css('background-image','url(&quot;images/interface/loader.gif&quot;)');
	 }

	 function hidePreloader()
	 {
	   $('#loader').css('background-image','url(&quot;&quot;)');
	 }

  });
</pre>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h2>Download, Demo &amp; Screencast</h2>
<p>&nbsp;</p>
<p><strong>Screencast</strong>: <a href="http://screenr.com/Z0W">http://screenr.com/Z0W</a>    <br />
<strong>Demo</strong>: <a href="http://www.addyosmani.com/resources/shinetime">http://www.addyosmani.com/resources/shinetime</a>    <br />
<strong>Download:</strong> <a href="http://www.addyosmani.com/resources/shinetime/shinetime.1.01.zip">http://www.addyosmani.com/resources/shinetime/shinetime.1.01.zip</a></p>
<p>&nbsp;</p>
<p>I hope that you found today&rsquo;s post a little helpful. If you&rsquo;d like to share it with your friends and colleagues or give me a thumbs up, feel free to click the <a class="retweet" href="http://addyosmani.com/blog/shinetime/">ShineTime &#8211; A jQuery &amp; CSS3 Gallery With Animated Shine Effects</a> button!. Thanks, guys.</p>
]]></content:encoded>
			<wfw:commentRss>http://addyosmani.com/blog/shinetime/feed/</wfw:commentRss>
		<slash:comments>40</slash:comments>
		</item>
		<item>
		<title>31 jQuery Snippets That Will Help Make You A JavaScript Pro</title>
		<link>http://addyosmani.com/blog/31-jquery-snippets/</link>
		<comments>http://addyosmani.com/blog/31-jquery-snippets/#comments</comments>
		<pubDate>Thu, 08 Apr 2010 01:18:59 +0000</pubDate>
		<dc:creator>Addy</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[cheatsheet]]></category>
		<category><![CDATA[Code Samples]]></category>
		<category><![CDATA[improve]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[javascript snippets]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery 1.3.2]]></category>
		<category><![CDATA[jquery 1.4]]></category>
		<category><![CDATA[jquery 1.4.2]]></category>
		<category><![CDATA[jquery clear]]></category>
		<category><![CDATA[jquery lessons]]></category>
		<category><![CDATA[jquery tutorials]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[samples]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://addyosmani.com/blog/?p=660</guid>
		<description><![CDATA[&#160;Hey guys. Hopefully if you&#8217;re reading this you&#8217;ve discovered some of the true power jQuery has to offer and you&#8217;re now looking for ways to improve your JavaScript skills even further. There was such a huge response to my last post on jQuery Snippets that I thought it only right to follow up with a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://addyosmani.com/blog/31-jquery-snippets/"><img width="530" height="342" border="0" alt="" src="http://addyosmani.com/blog/wp-content/uploads/31snip.jpg" /></a></p>
<p>&nbsp;Hey guys. Hopefully if you&#8217;re reading this you&#8217;ve discovered some of the true power jQuery has to offer and you&#8217;re now looking for ways to improve your JavaScript skills even further.</p>
<p>There was such a huge response to my last <a href="http://addyosmani.com/blog/50-jquery-snippets-for-developers/">post</a> on jQuery Snippets that I thought it only right to follow up with a fresh list that focuses on some of the more recent features introduced in jQuery 1.4.x. Because it&#8217;s always useful to have a second pair of eyes look over your code, I asked <a href="http://paulirish.com/">Paul Irish</a> from the jQuery Team to take a look at all of today&#8217;s snippets and he&#8217;s included some useful optimizations to a few of the snippets which I&#8217;ve intregated.</p>
<p><span id="more-660"></span></p>
<p>Now, if I only we could fit Paul into a useful Browser plugin, all my articles would be just as sensible <img src='http://addyosmani.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  The snippets from today can be applied to a wide range of projects so remember to bookmark the post if you find it useful so you can easily come back to it anytime you want. So without further adieu, I give you today&#8217;s 31 Snippets that will help make you a JavaScript Pro.</p>
<p>
<style type="text/css">
  #tiplist { list-style-type: decimal; }
 h1,h2 { font-family:Georgia;}
</style>
</p>
<div>&nbsp;</div>
<ul id="tiplist">
<li>
<h2>Did you know that using jQuery&#8217;s .live() function is more optimal for adding click functions than using .click()? It even handles dynamic content well.</h2>
<pre class="javascript" name="code">
$('.clickme').live('click', function() {
  // Live handler called.
});
</pre>
</li>
<li>
<h2>Attributes in jQuery &#8211; jQuery supports passing attributes for an object as the second argument to the jQuery function itself. This creates a new link on the page:</h2>
<pre class="javascript" name="code">
   $('', {
   text: 'jQuery is awesome!',
   href: 'http://www.jquery.com',
   id: 'someAwesomeID',
   rel: 'external',
   title: 'This is a title'
   }).appendTo('body');
</pre>
</li>
<li>
<h2>Function Grouping &#8211; jQuery supports binding functions so that they can all be defined within the same group. This can be useful for keeping your cody tidy among other things!</h2>
<pre class="javascript" name="code">
jQuery('#foo').bind({
    click: function() {
        // do something
    },
    mouseover: function() {
        // do something
    },
    mouseout: function() {
        // do something
    }
})
</pre>
</li>
<li>
<h2>Have you ever wanted to convert your JSON string into a JavaScript Object? Rather than having to custom code your own function to do it, just use jQuery&#8217;s built in .parseJSON function to achieve this easily (jQuery 1.4.1 and above):</h2>
<pre class="javascript" name="code">
var obj = jQuery.parseJSON('
    {&quot;name&quot;:&quot;Larry King&quot;,
     &quot;age&quot;: &quot;5000&quot;
    }');
alert( obj.name === &quot;Larry King&quot; ); //true
alert (obj.age  === &quot;50&quot;);//false
alert (obj.age  === &quot;5000&quot;); //true
</pre>
</li>
<li>
<h2>Ever since jQuery 1.4 you&#8217;ve been able to use a jQuery feature equivalent to PHP&#8217;s sleep() called delay. If you would like to delay and animated effect all you need to do is use delay as follows:</h2>
<pre class="javascript" name="code">
$('#myJaw').slideUp(300).delay(800).fadeIn(400);
 </pre>
</li>
<li>
<h2>When styling a large number of elements, instead of using css() it is more efficient to append a style tag to the DOM as follows:</h2>
<pre class="javascript" name="code">
$('
<style type="text/css"> div.class { color: red; } </style>

')
.appendTo('head');
</pre>
</li>
<li>
<h2>Here&#8217;s how you can remove the parent elements of any object using jQuery&#8217;s .unwrap() function</h2>
<pre class="javascript" name="code">
/* here we locate any paragraph elements and then
'unwrap' the parent elements around them. These
could be other divs, spans or anything really */

jQuery('p').unwrap();  
</pre>
</li>
<li>
<h2>Would you like to perform an action when an element or its contents gain focus? Here&#8217;s how to do it:</h2>
<pre class="javascript" name="code">
jQuery('form')
    .focusin(function(){
        jQuery(this).addClass('focused');
    });
    .focusout(function(){
        jQuery(this).removeClass('focused');
    });

//However, the preferred way to do this is using
// .focus() and .blur()

//For when an element loses it's focus use .blur()
$('#target').blur(function() {
  alert('Handler for .blur() called.');
});

//For when an element gains focus use .focus()
$('#target').focus(function() {
  alert('Handler for .focus() called.');
});
</pre>
</li>
<li>
<h2>Each traversal method in jQuery creates a new set which builds a stack. You can use .end() to reach the previous set.</h2>
<pre class="javascript" name="code">
$(&quot;
<ul>
<li>&nbsp;</li>
</ul>

&quot;) // li
  .find(&quot;a&quot;) // a
    .attr(&quot;href&quot;, &quot;http://www.google.com/&quot;) // a
    .html(&quot;Google!&quot;) // a
  .end() // li
  .appendTo(&quot;ul&quot;);
  </pre>
</li>
<li>
<h2>I&#8217;ve mentioned this a few times before, but it&#8217;s a feature that many developers forget exists within jQuery &#8211; data() &#8211; jQuery actually has an API for invisibly storing data on DOM nodes so you can easily store any information through JS and it&#8217;ll be available through the same central resource</h2>
<pre class="javascript" name="code">
$(&quot;div&quot;).data(&quot;myName&quot;, 'addy');
$(&quot;div&quot;).data(&quot;myName&quot;) === 'addy';
</pre>
</li>
<li>
<h2>Garbage collection of data stored can either be done through removeData() or via the remove() function after the element has been deleted.</h2>
<pre class="javascript" name="code">
/* Here are two ways to remove all of the information
bound to an element*/
$(&quot;div&quot;).removeData();
$(&quot;div&quot;).remove();
</pre>
</li>
<li>
<h2>Have you ever tried writing a plugin and run into a problem with overriding specific behaviours?. In jQuery you can override the values set or retrieved on the data method by binding to getData and setData.Returning a value will set/return a totally different result.</h2>
<pre class="javascript" name="code">
$(&quot;div&quot;).bind(&quot;getData.value&quot;, function()
{
  return myPlugin.realValue;
});
</pre>
</li>
<li>
<h2>jQuery supports namespacing and this includes namespacing data. You can scope your namespaces to a specific name or plugin and this can help you avoid conflicts with other code that might use the same data name.</h2>
<pre class="javascript" name="code">
/*
Why namespace? Namespacing ensures that your
variables don't conflict with any others which
happen to have the same name. This is important
if you want to avoid your code breaking when
other files or plugins are included in your
page's architecture. See below for an example of
namespacing data.
*/

$(&quot;div&quot;).data(&quot;events.plugin&quot;,
{
   //your data here
 });
</pre>
</li>
<li>
<h2>Looking for a way to namespace your event handlers?. This sample will show you his. It makes it easier to locate your namespace binding later on and easily remove the handler if needed.</h2>
<pre class="javascript" name="code">
$(&quot;div&quot;).bind(&quot;click.plugin&quot;, someFn);
$(&quot;div&quot;).bind(&quot;focus.plugin&quot;, otherFn);
$(&quot;div&quot;).unbind(&quot;.plugin&quot;);
</pre>
</li>
<li>
<h2>You can bind to almost any event and there aren&#8217;t really any limits on what you can or can&#8217;t bind to.</h2>
<pre class="javascript" name="code">
$(&quot;div&quot;).bind(&quot;myplugin&quot;, someFn);
$(&quot;div&quot;).trigger(&quot;myplugin&quot;);
</pre>
</li>
<li>
<h2>A good tip for complicated applications: Custom events are a useful way for multiple pieces of code to bind to the same functionality, so you trigger one event but lots of handlers can be executed.</h2>
<pre class="javascript" name="code">
$(&quot;div&quot;).bind(&quot;remove.pluginA&quot;, someFn);
$(&quot;div&quot;).bind(&quot;remove.pluginB&quot;, otherFn);
$(&quot;div&quot;).trigger(&quot;remove&quot;);
</pre>
</li>
<li>
<h2>Have you been trying to find a way to listen to events from a particular context? The delegate and undelegate methods make this possible (supported in jQuery 1.4.2 onwards). There&#8217;s also a very large performance gain got from switching over to .delegate()!</h2>
<pre class="javascript" name="code">
$(&quot;table&quot;).delegate(&quot;td&quot;, &quot;hover&quot;, function(){
  $(this).toggleClass(&quot;active&quot;);
});
</pre>
</li>
<li>
<h2>You can dynamically change the context of a function (if needed) using something similar to this. Since jQuery 1.4.* you&#8217;ve also been able to easily remove the proxied function.</h2>
<pre class="javascript" name="code">
var obj = { method: function(){} };
$(&quot;#foo&quot;).click( jQuery.proxy( obj, &quot;method&quot; ) );
$(&quot;#foo&quot;).unbind( &quot;click&quot;, obj.method );
</pre>
</li>
<li>
<h2>Interested in creating a simple custom selector?. Creating your own selectors is easy and you can do this for your plugins if you would like some easy querying features.</h2>
<pre class="javascript" name="code">
jQuery.expr[&quot;:&quot;].myplugin = function(elem) {
  return !!jQuery.data(&quot;myplugin&quot;);
};
</pre>
</li>
<li>
<h2>Did you know that you can treat jQuery objects like arrays?. Take a look at this example.</h2>
<pre class="html" name="code">
/*Here's some sample HTML followed by some jQuery
that allows us to access the values of any &quot;box&quot;
by index.*/
<div id="wrapper">
<div class="box">Content #1!</div>
<div class="box">Content #2!</div>
<div class="box">Content #3!</div>
<div class="box">Content #4!</div>
</div>
<div id="wrapper2">
<div class="box">Content2 #1!</div>
</div>
</pre>
</li>
<pre class="javascript" name="code">

// returns 4
$('#wrapper .box').length;

// num is equal to 4
var num = $('#wrapper .box');
num = num.length;

// text is equal to 'Content #2!'
var text = $(&quot;#wrapper .box&quot;)[1];

// text is equal to 'Content #1'
var text = $(&quot;#wrapper .box&quot;)[0];

// text is equal to 'Content2 #1'
var text = $(&quot;#wrapper2 .box&quot;)[0];
</pre>
<li>
<h2>Selection storage: Did you know that you can store the results from a jQuery selection in a variable and *still* have access to the same methods?. Here&#8217;s a useful example.</h2>
<pre class="javascript" name="code">
var $myBox = $('#test');
/*the variable myHTML is equal to the content's of
'#test'*/
var myHTML = $myBox.html();
</pre>
</li>
<li>
<h2>Did you know that jQuery has great support for Callbacks? Here are two ways you can tell if a function has completed running.</h2>
<pre class="javascript" name="code">
function runAlertNow ()
{
	$(this).html('I just ran this function!');
}

// both of these lines do the same thing
$('#test').slideUp(400, runAlertNow);
$('#test').slideUp(400, function ()
{
$(this).html('I just ran the anonymous function!');
});
</pre>
</li>
<li>
<h2>Very useful tip: Did you know that you can select elements within another element just by passing a second parameter to the jQuery initializer?</h2>
<pre class="html" name="code">
<div id="yourparent">
<div id="mychild">&nbsp;</div>
</div>
</pre>
</li>
<p>    Here are three ways to access an element within an element:</p>
<pre class="javascript" name="code">
$('#yourparent').find('#mychild')
//or even shorter:
$('#mychild', $('#yourparent'))
//or even shorter:
$('#mychild', '#yourparent')
</pre>
<li>
<h2>How do you handle access to elements with IDs that contain special characters in jQuery?</h2>
<pre class="javascript" name="code">
$(&quot;$some[id]&quot;).show(); // won't work for this type of ID
$(&quot;$some\\[id\\]&quot;).show() // works fine for the ID: some[id]
</pre>
</li>
<li>
<h2>How do you enable or disable form elements within jQuery?</h2>
<pre class="javascript" name="code">
//To disable a form element such as a text input field
$(&quot;#myelement&quot;).attr(&quot;disabled&quot;, &quot;disabled&quot;);

//To re-enable a disabled form element
$(&quot;#myelement&quot;).removeAttr(&quot;disabled&quot;);
</pre>
</li>
<li>
<h2>How do you check if something exists in the DOM using jQuery:</h2>
<pre class="javascript" name="code">
/*The .length property in jQuery returns the length
or number of elements inside an array or the string
length. If you want to check the existence of the
element, just check if the returned value of length
is zero:*/

if ($(selector).length)
{
   //your code here
}
</pre>
</li>
<li>
<h2>How do you search all the nodes on a page for a particular piece of text using jQuery?</h2>
<pre class="javascript" name="code">
/*This useful extended function will allow you to
pattern match a keyword across all the nodes in a
page. See the example below for how GMail use something
similar in concept for their search-keyword highlighting*/

$.fn.egrep = function(pat) {
 var out = [];
 var textNodes = function(n) {
  if (n.nodeType == Node.TEXT_NODE) {
   var t = typeof pat == 'string' ?
    n.nodeValue.indexOf(pat) != -1 :
    pat.test(n.nodeValue);
   if (t) {
    out.push(n.parentNode);
   }
  }
  else {
   $.each(n.childNodes, function(a, b) {
    textNodes(b);
   });
  }
 };
 this.each(function() {
  textNodes(this);
 });
 return out;
};

// Here's an example of using this to highlight
//all the nodes on the page that contain the keyword
//'jQuery'
$(&quot;#testbutton&quot;).click(function()
{
var n = $('body').egrep(/jquery/i);
for (var i = 0; i &lt; n.length; ++i)
{
   void($(n[i]).css('background', 'yellow'));
 }
});
</pre>
</li>
<li>
<h2>Have you ever wanted to retain any of the information .remove() strips from the DOM? The .detach() method is a lot like remove() except that .detach() keeps all jQuery data associated with the removed elements. This is useful when you want to reinsert removed elements into the DOM later.</h2>
<pre class="javascript" name="code">
//In the below example
$(&quot;p&quot;).click(function(){
      $(this).toggleClass(&quot;off&quot;);
    });
    var p;
    $(&quot;button&quot;).click(function(){
      if ( p ) {
        p.appendTo(&quot;body&quot;);
        p = null;
      } else {
        p = $(&quot;p&quot;).detach();
      }
    });
</pre>
</li>
<li>
<h2>You can easily find the closest element to another (beginning at the current element and moving up the DOM) using .closest(). See the below example:</h2>
<pre class="javascript" name="code">
$(document).ready(function()
{
//Let's set the background color of the nearest
//UL in this pseudo-menu
$('li.subchild').closest('ul').css('background-color', 'red');
});
</pre>
<pre class="html" name="code">
<ul>
<li>Parent Menu
<ul>
<li class="subchild">Child Item 1</li>
<li class="subchild">Child Item 2</li>
</ul>
</li>
</ul>
</pre>
</li>
<li>
<h2>How to easily and quickly add one-click clearing of default input text values from your fields</h2>
<pre class="javascript" name="code">
(function($){
	$.fn.clearDefault = function(){
		return this.each(function(){
			var default_value = $(this).val();
			$(this).focus(function(){
				if ($(this).val() == default_value)
                              $(this).val(&quot;&quot;);
			});
			$(this).blur(function(){
				if ($(this).val() == &quot;&quot;)
                              $(this).val(default_value);
			});
		});
	};
})(jQuery);

// How to use it: $('input').clearDefault();
</pre>
</li>
<li>
<h2>Would you like to style only a particular range of elements within a list? jQuery&#8217;s .slice() function makes this possible through indices</h2>
<pre class="html" name="code">
<ul>
<li>Apples</li>
<li>Pears</li>
<li>Cherries</li>
<li>Grapes</li>
<li>Mangos</li>
</ul>
</pre>
<pre class="javascript" name="code">
  /*If we just want to set the background-color of
    everything after element number two (pears) we
   can do this using:*/

	$('li').slice(2).css('background-color', 'yellow');

 /*and if we want to set the bg-color of the elements
   after two(pears), but only up to and including 4
   (grapes), we can use:*/
   $('li').slice(2, 4).css('background-color', 'green')
</pre>
</li>
<p>I hope you found those useful!. If so, feel free to hit the <a href="http://addyosmani.com/blog/31-jquery-snippets/" class="retweet">31 jQuery Snippets That Will Make You A JavaScript Pro (via @addyosmani)</a>button so you can share it with all your friends and colleagues.</p>
<p>Good luck with your JavaScript!</p>
<p>- Addy</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://addyosmani.com/blog/31-jquery-snippets/feed/</wfw:commentRss>
		<slash:comments>37</slash:comments>
		</item>
		<item>
		<title>The Ultimate Guide To JavaScript in Web Design</title>
		<link>http://addyosmani.com/blog/the-ultimate-guide-to-javascript-in-web-design/</link>
		<comments>http://addyosmani.com/blog/the-ultimate-guide-to-javascript-in-web-design/#comments</comments>
		<pubDate>Sun, 21 Mar 2010 03:59:16 +0000</pubDate>
		<dc:creator>Addy</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[javascript in web design]]></category>
		<category><![CDATA[javascript tutorials]]></category>
		<category><![CDATA[jquery in web design]]></category>
		<category><![CDATA[jquery tutorials]]></category>
		<category><![CDATA[jquery web design]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[web design explained]]></category>
		<category><![CDATA[web designers]]></category>
		<category><![CDATA[web designing]]></category>

		<guid isPermaLink="false">http://addyosmani.com/blog/the-ultimate-guide-to-javascript-in-web-design/</guid>
		<description><![CDATA[&#160; &#160; In today&#8217;s post, we&#8217;re going to take a look at how you can effectively use JavaScript in Web Design. JavaScript has allowed web designers to easily enrich their visual designs with new features and elements that can make using a website a much more interactive, intuitive and enjoyable experience. In recent years, the [...]]]></description>
			<content:encoded><![CDATA[<p><img title="javault" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="342" alt="javault" width="530" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/javault.jpg" /></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>In today&rsquo;s post, we&rsquo;re going to take a look at how you can effectively use JavaScript in Web Design. JavaScript has allowed web designers to easily enrich their visual designs with new features and elements that can make using a website a much more interactive, intuitive and enjoyable experience. In recent years, the introduction of JavaScript frameworks such as jQuery, MooTools, Scriptalicious and ExtJS has simplified this process considerably, allowing designers to be innovative with their user interfaces. To begin today&rsquo;s post, let&rsquo;s take a look at a generic wireframe to your typical website.</p>
<p>&nbsp;</p>
<p><span id="more-591"></span></p>
<p>Below you can see a wireframe that consists of a header, a login area, central page elements, a search box, a sidebar, banner adverts, a footer, floating elements and a website toolbar. This could easily be a blog-site, a business&rsquo;s official website or any number of different projects.</p>
<p>&nbsp;</p>
<p>As designers, most of our pages share a few key elements and I believe that the elements in this diagram represent the majority of those we might encounter on a daily basis.</p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/pagecontents.jpg"><img title="pagecontents" style="border-top-width: 0px; display: block; border-left-width: 0px; float: none; border-bottom-width: 0px; margin-left: auto; margin-right: auto; border-right-width: 0px" height="305" alt="pagecontents" width="472" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/pagecontents_thumb.jpg" /></a></p>
<p>&nbsp;</p>
<p>So, let&rsquo;s imagine for a moment that we&rsquo;ve just created a basic layout for a site using the above as a guideline. We know that we can style any of the elements in this layout using either CSS or some PSD graphics, but what if we want to add more interactivity to our elements so that they allow our users to *do* more with the site?.&nbsp; This is where JavaScript can come in useful.</p>
<p>&nbsp;</p>
<p>JavaScript offers a whole wealth of benefits to web designers and web developers. Let&rsquo;s go through some of them. If I have a standard search box on my site, that allows my users to search through the content that&rsquo;s available and if they&rsquo;re lucky enough, they&rsquo;ll find what they&rsquo;re looking for. If however, I have a JavaScript powered Search-Box that offers them auto-complete features, they&rsquo;ll be able to quickly and easily refine their search queries to get the content they want, without needing to reload the search page lots of times.</p>
<p>&nbsp;</p>
<p><img title="diagram1" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="320" alt="diagram1" width="550" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/diagram1.jpg" /></p>
<p>&nbsp;</p>
<p>We&rsquo;ve just introduced a time-saving feature and that&rsquo;s going to make life easier for our users. These are the kinds of functional benefits introducing JavaScript powered elements into your design can offer to the people who are going to be using your pages the most.</p>
<p>&nbsp;</p>
<p>JavaScript can also offer a lot of benefits to you as a web designer. Let&rsquo;s say that your site depends on ad-revenue a lot and that to maximize this, you might need to be conservative with your use of space. This can have major impacts on your design if you&rsquo;re just using a CSS/XHTML layout, but not if you&rsquo;re using JavaScript to help solve the problem. As an example, if I wanted to include a login-form at the top of my page, but couldn&rsquo;t because we need that space for adverts, I could easily introduce a JavaScript powered button in it&rsquo;s place that could slide-down the login area whenever someone needed it. The result? I, the designer, get to include my login area at the top of the page afterall but the site&rsquo;s advertising needs don&rsquo;t have to be scarified.</p>
<p>&nbsp;</p>
<p>It can be safely said that JavaScript has had a huge impact on the web design landscape. Looking at just one JavaScript framework alone, jQuery itself now powers almost 20% of websites online. With this in mind I would certainly recommend continuous learning about your framework of choice so that you get ideas for what&rsquo;s possible with your interfaces. Just remember to cover the basic JavaScript fundamentals before hopping onto the framework bandwagon!.</p>
<p>&nbsp;</p>
<p>Okay, so let&rsquo;s get to the really useful content in this post. I wanted to show you guys how you can use JavaScript (in this case jQuery) to enhance all aspects of conventional Web Design, from things you can use JavaScript for to make your Header more interactive, to tutorials you can use to create innovative new menus or search features that your users and clients will be impressed with. We&rsquo;re going to start from the top of the page (with Login Forms) and end it with website toolbars.</p>
<p>&nbsp;</p>
<p>I hope you find the post useful!</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><strong><font face="Georgia" size="4">Login Button/Form</font></strong></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="http://aext.net/2009/08/perfect-sign-in-dropdown-box-likes-twitter-with-jquery/">Twitter-like Sign-in Box for Your Header</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="151" alt="image" width="520" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb.png" /></a></p>
<p>&nbsp;</p>
<p><a href="http://www.topnotchthemes.com/blog/081204/horizontal-user-login-block-using-css-and-jquery">Horizontal User Login Block Using jQuery &amp; CSS</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image1.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="154" alt="image" width="522" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb1.png" /></a></p>
<p>&nbsp;</p>
<p><a href="http://www.cssjockey.com/coding/jquery-css-login-panel">An easy-to-create Login Panel with jQuery and CSS</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image2.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="152" alt="image" width="521" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb2.png" /></a></p>
<p>&nbsp;</p>
<p><a href="http://shawnmccool.com/2009/04/15/ajax-with-jquery-a-simple-login-example/">An Ajax &amp; jQuery Simple Login Example</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image3.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="155" alt="image" width="525" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb3.png" /></a></p>
<p>&nbsp;</p>
<p><a href="http://wpmu.org/how-to-create-a-sliding-jquery-login-panel-for-wordpress-wpmu-and-buddypress/">A Sliding jQuery Login Panel for WordPress &amp; Buddypress</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image4.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="152" alt="image" width="521" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb4.png" /></a>     </p>
<p>&nbsp;</p>
<p><a href="http://fearlessflyer.com/2009/06/how-to-create-a-slick-jquery-login-form-for-wordpress/">How to create a slick jQuery Login Form for WordPress</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image5.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="153" alt="image" width="520" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb5.png" /></a></p>
<p>&nbsp;</p>
<p><a href="http://blog.popstalin.com/articles/wordpress/wordpress-front-page-login">WordPress Front-page login with jQuery Sliding Panel</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image6.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="153" alt="image" width="520" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb6.png" /></a>     </p>
<p>&nbsp;</p>
<p><a href="http://jvance.com/pages/JQueryOpenIDPlugin.xhtml">jQuery OpenID Login Form</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image7.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="157" alt="image" width="525" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb7.png" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><strong><font face="Georgia" size="4">Search Box</font></strong>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="http://www.9lessons.info/2009/08/twitter-like-search-with-jquery-ajax.html">How To Create A Twitter-like Search With jQuery and Ajax</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image8.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="155" alt="image" width="520" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb8.png" /></a></p>
<p>&nbsp;</p>
<p><a href="http://www.marcofolio.net/webdesign/a_fancy_apple.com-style_search_suggestion.html">How To Create An Apple-Style Search Suggestion Form</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image9.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="159" alt="image" width="517" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb9.png" /></a>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="http://yensdesign.com/2009/01/improving-search-boxes-with-jquery/">How to Improve your search boxes with jQuery</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image10.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="158" alt="image" width="514" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb10.png" /></a></p>
<p>&nbsp;</p>
<p><a href="http://return-true.com/2009/08/how-to-jquery-autocomplete/">How to Easily add AutoComplete features to your searchbox</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image11.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="166" alt="image" width="520" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb11.png" /></a>&nbsp; </p>
<p>&nbsp;</p>
<p><a href="http://www.web2ajax.fr/examples/facebook_searchengine/">How To Create a Facebook-Like Search UI using jQuery</a>&nbsp;</p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image12.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="165" alt="image" width="516" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb12.png" /></a></p>
<p>&nbsp;</p>
<p><a href="http://fromvega.com/wordpress/2007/05/05/auto-complete-field-with-jquery-json-php/">jQuery AutoComplete Tutorial (jQuery + JSON + PHP)</a>&nbsp;</p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image13.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="165" alt="image" width="518" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb13.png" /></a></p>
<p>&nbsp;</p>
<p><a href="http://aspdotnetpatterns.blogspot.com/2009/08/jquery-autocomplete-using-xml-with-key.html">jQuery AutoComplete Tutorial (jQuery + XML)</a>&nbsp;</p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image14.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="167" alt="image" width="518" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb14.png" /></a></p>
<p>&nbsp;</p>
<p><a href="http://www.it-eye.nl/weblog/2008/08/23/using-jquery-autocomplete-with-grails-and-json/">jQuery AutoComplete Tutorial (jQuery + JSON + GRAILS)</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image15.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="170" alt="image" width="520" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb15.png" /></a></p>
<p>&nbsp;</p>
<p><a href="http://viralpatel.net/blogs/2009/06/tutorial-create-autocomplete-feature-with-java-jsp-jquery.html">jQuery AutoComplete Tutorial (jQuery + JAVA + JSP )</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image16.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="174" alt="image" width="519" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb16.png" /></a>     </p>
<p>&nbsp;</p>
<p><a href="http://www.moretechtips.net/2009/10/realtime-realted-stream-bar-collecta.html">Mike More&#8217;s Realtime Search Stream</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image17.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="174" alt="image" width="520" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb17.png" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><strong><font face="Georgia" size="4">Page Header</font></strong></p>
<p>&nbsp;</p>
<p>
<a href="http://captionslider.allwww.nl/">jQuery Caption Slider for your Header</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image18.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="194" alt="image" width="520" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb18.png" /></a>     </p>
<p>&nbsp;</p>
<p><a href="http://davidwalsh.name/persistent-header-opacity">A Persistant jQuery Header</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image19.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="199" alt="image" width="520" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb19.png" /></a>     </p>
<p>&nbsp;</p>
<p><a href="http://spritely.net/">A Sprite-Based jQuery Animated Header</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image20.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="204" alt="image" width="522" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb20.png" /></a>     </p>
<p>&nbsp;</p>
<p><a href="http://buildinternet.com/2009/02/how-to-make-an-impressive-animated-landscape-header-with-jquery/">An Impressive Animated Landscape with jQuery</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image21.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="203" alt="image" width="519" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb21.png" /></a></p>
<p>&nbsp;</p>
<p><a href="http://www.devirtuoso.com/2009/07/how-to-build-an-animated-header-in-jquery/">How to build an animated Header in jQuery</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image22.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="201" alt="image" width="508" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb22.png" /></a>     </p>
<p>&nbsp;</p>
<p><a href="http://design-notes.info/tutorial/jquery-tutorial/make-your-header-responses-to-mouse-movements-with-jparallax/">Parallax based Header in jQuery</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image23.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="207" alt="image" width="502" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb23.png" /></a>     </p>
<p>&nbsp;</p>
<p><a href="http://www.ultramegatech.com/blog/2009/06/create-a-slide-in-panel-jquery/">Slide-in Panel with jQuery</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image24.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="198" alt="image" width="498" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb24.png" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><strong><font face="Georgia" size="4">Page Adverts &amp; Banners</font></strong></p>
<p>&nbsp;</p>
<p><a href="http://www.mclelun.com/blog/2010/01/jquery-rotating-banner/">jQuery Rotating Banner 1</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image25.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="180" alt="image" width="513" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb25.png" /></a>     </p>
<p>&nbsp;</p>
<p><a href="http://mynichecomputing.org/RotBan/">jQuery Rotating Banner 2</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image26.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="180" alt="image" width="513" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb26.png" /></a></p>
<p>&nbsp;</p>
<p>
<a href="http://www.cssnewbie.com/jquery-popout-ad-part-1/">jQuery Pop-out Ad</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image27.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="183" alt="image" width="514" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb27.png" /></a></p>
<p>&nbsp;</p>
<p><a href="http://www.smple.com/pagePeel/">jQuery Page Peel</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image28.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="183" alt="image" width="515" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb28.png" /></a></p>
<p>&nbsp;</p>
<p>
<a href="http://www.wdxperience.ch/jquery/cornads/">jQuery Corner-Ads</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image29.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="183" alt="image" width="509" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb29.png" /></a>&nbsp;</p>
<p>&nbsp;</p>
<p>
<a href="http://andreaslagerkvist.com/jquery/vibrate/">jQuery Vibrate</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image30.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="186" alt="image" width="506" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb30.png" /></a></p>
<p>&nbsp;</p>
<p>
<a href="http://www.devcurry.com/2009/06/text-link-ad-rotation-using-jquery.html">jQuery Text-Link Ad Rotation</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image31.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="187" alt="image" width="504" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb31.png" /></a></p>
<p>&nbsp;</p>
<p><a href="http://tympanus.net/codrops/2009/12/16/creating-a-rotating-billboard-system-with-jquery-and-css/">Creating a Rotating Billboard System with jQuery &amp; CSS</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image32.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="202" alt="image" width="509" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb32.png" /></a>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><strong><font face="Georgia" size="4">Navigation</font></strong></p>
<p>
<a href="http://net.tutsplus.com/tutorials/html-css-techniques/how-to-build-a-lava-lamp-style-navigation-menu/">How To Build A LavaLamp Style jQuery Menu</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image33.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="198" alt="image" width="501" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb33.png" /></a></p>
<p>&nbsp;</p>
<p><a href="http://www.1stwebdesigner.com/resources/36-eye-catching-jquery-navigation-menus/">36 Eye Catching jQuery Navigation Menu</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image34.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="201" alt="image" width="507" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb34.png" /></a></p>
<p>&nbsp;</p>
<p><a href="http://www.catswhocode.com/blog/10-incredible-jquery-navigation-menus">10 Incredible jQuery Navigation Menus</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image35.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="203" alt="image" width="509" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb35.png" /></a>     </p>
<p>&nbsp;</p>
<p><a href="http://speckyboy.com/2009/06/08/24-css-in-some-cases-with-jquery-navigation-and-menu-tutorials/">24 CSS/jQuery Navigation Menus</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image36.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="192" alt="image" width="490" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb36.png" /></a>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="http://www.noupe.com/jquery/45-jquery-navigation-plugins-and-tutorials.html">45 jQuery Navigation Plugins And Tutorials</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image37.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="183" alt="image" width="486" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb37.png" /></a>     </p>
<p>&nbsp;</p>
<p><a href="http://blueprintds.com/2009/10/29/jquery-for-web-design-navigation/">jQuery Navigation For Web Design</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image38.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="190" alt="image" width="484" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb38.png" /></a>     </p>
<p>&nbsp;</p>
<p><a href="http://www.hongkiat.com/blog/drop-down-menu-30-free-scripts-to-enhance-header-navigation/">30 jQuery Drop-Down Menus For Navigation</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image39.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="188" alt="image" width="477" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb39.png" /></a>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="http://net.tutsplus.com/tutorials/design-tutorials/how-to-build-and-enhance-a-3-level-navigation-menu/">How to Build and Enhance a 3-Level Navigation Menu</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image40.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="187" alt="image" width="471" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb40.png" /></a></p>
<p>&nbsp;</p>
<p><a href="http://net.tutsplus.com/tutorials/javascript-ajax/a-different-top-navigation/">A Different Top Navigation</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image41.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="186" alt="image" width="467" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb41.png" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><strong><font face="Georgia" size="4">Page Elements</font></strong></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="http://desandro.com/resources/jquery-masonry">jQuery Masonry</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image42.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="187" alt="image" width="460" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb42.png" /></a></p>
<p>&nbsp; <br />
<a href="http://welcome.totheinter.net/columnizer-jquery-plugin/">jQuery Colomnizer Plugin</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image43.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="187" alt="image" width="459" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb43.png" /></a></p>
<p>&nbsp;</p>
<p><a href="http://layout.jquery-dev.net/">jQuery UI Layout Plugin</a>&nbsp;</p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image44.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="191" alt="image" width="465" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb44.png" /></a></p>
<p>
<a href="http://code.google.com/p/js-columns/">jQuery Columns Plugin</a></p>
<p>&nbsp;</p>
<p><a href="http://www.jankoatwarpspeed.com/post/2009/11/08/YouTube-adaptable-view-css-jquery.aspx">YouTube-Like jQuery Adaptable Views</a></p>
<p>&nbsp;</p>
<p>
<a href="http://jqueryplugins.codeplex.com/">jQuery Layout Background Plugins</a></p>
<p>&nbsp;</p>
<p><a href="http://www.trilancer.com/jpolite2/index1.html">jPolite jQuery Layout Plugin</a></p>
<p>&nbsp;</p>
<p><a href="http://jqueryplugins.codeplex.com/">Layout Background Plugin</a></p>
<p>&nbsp;</p>
<p><a href="http://blog.jeremymartin.name/2008/02/blogger-trick-style-author-comments.html">Style Author Comments Differently with jQuery</a>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="http://www.webdesignerwall.com/tutorials/jquery-sequential-list/">jQuery Sequential List</a></p>
<p>&nbsp;</p>
<p><a href="http://www.komodomedia.com/blog/2008/10/jquery-feed-menus/">jQuery Feed Menu</a></p>
<p>&nbsp;</p>
<p><a href="http://plugins.learningjquery.com/expander/index.html">Read More Button Options (1)</a></p>
<p>&nbsp;</p>
<p><a href="http://www.reindel.com/truncate/">Read More Button Options (2)</a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><strong><font face="Georgia" size="4">Sidebars</font></strong>&nbsp; </p>
<p>&nbsp;</p>
<p><a href="http://www.queness.com/resources/html/scrollto/index.html">jQuery Sidebar Sliding Tab Menu Tutorial</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image45.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="208" alt="image" width="505" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb45.png" /></a>     </p>
<p>&nbsp;</p>
<p><a href="http://sidearmdesign.com/post/2009/jun/13/jquery-part-one-dynamic-collapsable-sidebar/">jQuery Dynamic Collapsible Sidebar</a>&nbsp;</p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image46.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="208" alt="image" width="510" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb46.png" /></a>     </p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="http://www.dvq.co.nz/jquery/creating-a-sliding-sidebar-that-follows-the-user/">Creating A Sliding Sidebar That Follows The User</a></p>
<p>&nbsp;</p>
<p><img height="178" width="508" alt="" src="http://www.dvq.co.nz/wp-content/uploads/2009/04/sliding-sidebar-preview.jpg" /></p>
<p>&nbsp;</p>
<p><a href="http://www.catswhocode.com/blog/8-amazing-jquery-accordions">8 Amazing jQuery Accordians</a>&nbsp;</p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image47.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="206" alt="image" width="501" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb47.png" /></a>     </p>
<p><a href="http://www.parrisstudios.com/?p=339">Sliding SideBar Menu in JQuery</a>&nbsp;</p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image48.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="210" alt="image" width="505" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb48.png" /></a>     </p>
<p>&nbsp;</p>
<p><a href="http://net.tutsplus.com/html-css-techniques/how-to-create-a-mootools-homepage-inspired-navigation-effect-using-jquery/">How To Create A &#8216;Mootools Homepage&#8217; Inspired Navigation Effect Using jQuery</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image49.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="210" alt="image" width="499" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb49.png" /></a>&nbsp;&nbsp; </p>
<p>&nbsp;</p>
<p><a href="http://net.tutsplus.com/tutorials/wordpress/wordpress-sidebar-turned-apple-flashy-using-jquery-ui/">Apple Flashy jQuery Sidebar</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image50.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="200" alt="image" width="490" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb50.png" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><strong><font face="Georgia" size="4">Floating Elements</font></strong>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="http://www.developersnippets.com/2009/04/25/floating-slidein-menu-with-anchor-link-using-jquery/">jQuery Floating Slide-In Menu with Anchor Link</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image51.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="206" alt="image" width="506" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb51.png" /></a></p>
<p>&nbsp;</p>
<p><a href="http://slightlyremarkable.com/blog/2009/01/25/floating-comment-form/">jQuery Floating Comment-Form</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image52.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="192" alt="image" width="495" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb52.png" /></a></p>
<p>&nbsp;</p>
<p><a href="http://net.tutsplus.com/html-css-techniques/creating-a-floating-html-menu-using-jquery-and-css/">Create a Floating Menu with jQuery</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image53.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="193" alt="image" width="504" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb53.png" /></a></p>
<p>&nbsp;</p>
<p><a href="http://creativeurbia.com/tuts/create-a-floating-navigation-using-html-css-and-jquery/">Create Floating Navigation using jQuery</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image54.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="192" alt="image" width="501" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb54.png" /></a></p>
<p>&nbsp;</p>
<p><a href="http://sideroad.secret.jp/plugins/jQueryFloatingMessage/">jQuery Floating Message Plugin</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image55.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="205" alt="image" width="509" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb55.png" /></a></p>
<p>&nbsp;</p>
<p><a href="http://roshanbh.com.np/2008/07/top-floating-message-box-using-jquery.html">jQuery Top-Floating Message Box</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image56.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="197" alt="image" width="488" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb56.png" /></a></p>
<p>&nbsp;</p>
<p><a href="http://www.jquery-sticky-notes.com/">jQuery Sticky Floating Notes</a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image57.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="186" alt="image" width="482" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb57.png" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><strong><font face="Georgia" size="4">Call-To-Action Buttons</font></strong>     </p>
<p>&nbsp;</p>
<p><a href="http://www.jquery.wisdomplug.com/jquery-plugins/jquery-user-interface-plugins-jquery-plugins/create-an-animated-call-to-action-button/">Create an Animated Call To Action Button with jQuery</a>     </p>
<p><a href="http://www.jquery.wisdomplug.com/jquery-plugins/jquery-user-interface-plugins-jquery-plugins/jquery-animated-buttons-using-css/">jQuery Animated Buttons with CSS</a>&nbsp; </p>
<p><a href="http://theodin.co.uk/blog/design/fancy-radio-buttons-jquery.html">jQuery Fancy Radio Buttons</a>     </p>
<p><a href="http://www.jquery.wisdomplug.com/jquery-plugins/jquery-animation-effects-plugins-jquery-plugins/glowbuttons-using-jquery/">jQuery GlowButtons</a>     </p>
<p><a href="http://www.jquery.wisdomplug.com/jquery-plugins/jquery-user-interface-plugins-jquery-plugins/jquery-ui-buttons/">jQuery UI Buttons tutorial</a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><strong><font face="Georgia" size="4">Sharing Elements</font></strong>&nbsp; </p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="http://www.webresourcesdepot.com/drag-to-share-like-mashable-com-with-jquery/">Create a Mashable-Style Drag To Share With jQuery</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image58.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="198" alt="image" width="517" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb58.png" /></a></p>
<p>&nbsp;</p>
<p><a href="http://henryladcases.com/social-icons-with-cool-jquery-tooltip/">Social Sharing Icons With A Cool jQuery ToolTip</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image59.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="199" alt="image" width="514" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb59.png" /></a></p>
<p>&nbsp;</p>
<p><a href="http://guidesigner.net/casecade-style-sheet/learn-how-to-create-fancy-share-box-with-css-and-jquery/">Create a Fancy Share Box with CSS And jQuery</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image60.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="201" alt="image" width="525" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb60.png" /></a>     </p>
<p>&nbsp;</p>
<p><a href="http://www.michael-louviere.com/2009/11/30/social-media-icons-jquery-menu/">How to Create a Social Menu with jQuery</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image61.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="203" alt="image" width="525" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb61.png" /></a></p>
<p>&nbsp;</p>
<p><a href="http://www.joanpiedra.com/jquery/shareit/">A jQuery Version of ShareIt</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image62.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="197" alt="image" width="514" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb62.png" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;&nbsp;&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><strong><font face="Georgia" size="4">Page Footer</font></strong>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="http://johnpatrickgiven.com/jquery/pinned-footer/">How to create a Pinned Footer for your site</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image63.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="201" alt="image" width="518" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb63.png" /></a>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="http://www.emanueleferonato.com/2010/03/03/create-a-dynamic-content-animated-footer-ad-for-your-site-in-just-15-jquery-lines/">How to create a dynamic animated footer ad for your site</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image64.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="203" alt="image" width="524" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb64.png" /></a>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="http://www.drupalcoder.com/story/500-cross-browser-sticky-footer-with-fluid-height-using-jquery">Cross-browser Sticky Footer with Fluid Height</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image65.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="203" alt="image" width="525" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb65.png" /></a>     </p>
<p>&nbsp;</p>
<p><a href="http://www.hardcode.nl/archives_139/article_244-jquery-sticky-footer">How to create a Sticky-Footer</a></p>
<p>&nbsp;</p>
<p><a href="http://www.maifith.com/news/use-jquery-to-automatically-size-your-footer-height">How to automatically use jQuery to size your footer Height</a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><strong><font face="Georgia" size="4">Fixed-Position Website Toolbars</font></strong>     </p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="http://addyosmani.com/blog/jquery-fubar-how-to-create-a-website-toolbar-from-scratch-and-add-widgets-to-it/">How To Create a Website Toolbar And Add Widgets to it</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image66.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="203" alt="image" width="523" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb66.png" /></a></p>
<p>&nbsp;</p>
<p><a href="http://www.sohtanaka.com/web-design/examples/footer-panel/">Facebook Style Footer-Toolbar from Soh Tanaka</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image67.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="204" alt="image" width="521" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb67.png" /></a></p>
<p>&nbsp;</p>
<p>J<a href="http://ryan.rawswift.com/sandbox/jixedbar-0.0.2/demo/">ixedBar &ndash; A Fixed-Position Toolbar plugin for jQuery</a></p>
<p>&nbsp;</p>
<p><a href="http://www.bennadel.com/blog/1740-Building-A-Fixed-Position-Bottom-Menu-Bar-ala-FaceBook-.htm">Floating Footer Toolbar</a></p>
<p>&nbsp;</p>
<p><a href="http://www.pvmgarage.com/en/2009/12/nice-and-simple-toolbar-for-your-website-with-css3-and-jquery/">CSS3 Fixed-Position Toolbar for your site with Social Networking Icons</a></p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://addyosmani.com/blog/wp-content/uploads/2010/03/image68.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="209" alt="image" width="515" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/image_thumb68.png" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>And that&rsquo;s it!. If you&rsquo;re interested in learning more about jQuery and JavaScript and would like to stay up to date with the latest articles, please feel free to subscribe to the <a href="http://feeds.feedburner.com/addyosmani">RSS feed</a>. Alternatively, you can access to my weekly and daily JavaScript recommendations by joining either my <a href="http://bit.ly/addyosmani">Fan page</a> or my Facebook Group, <a href="http://www.facebook.com/group.php?gid=10150090669430508&amp;ref=ts">jQuery Awesome</a>. Thanks!</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a class="thickbox" href="http://www.facebook.com/group.php?gid=10150090669430508&amp;ref=ts"><img title="IMAGE_844" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="339" alt="IMAGE_844" width="512" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/IMAGE_844.jpg" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://addyosmani.com/blog/the-ultimate-guide-to-javascript-in-web-design/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>50 jQuery Snippets That Will Help You Become A Better JavaScript Developer</title>
		<link>http://addyosmani.com/blog/50-jquery-snippets-for-developers/</link>
		<comments>http://addyosmani.com/blog/50-jquery-snippets-for-developers/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 14:28:56 +0000</pubDate>
		<dc:creator>Addy</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[bind]]></category>
		<category><![CDATA[custom functions]]></category>
		<category><![CDATA[custom methods]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery 1.3.2]]></category>
		<category><![CDATA[jquery 1.4.2]]></category>
		<category><![CDATA[jquery binding]]></category>
		<category><![CDATA[jquery custom functions]]></category>
		<category><![CDATA[jquery developers]]></category>
		<category><![CDATA[jquery functions]]></category>
		<category><![CDATA[jquery has]]></category>
		<category><![CDATA[jquery images]]></category>
		<category><![CDATA[jquery nesting]]></category>
		<category><![CDATA[jquery samples]]></category>
		<category><![CDATA[jquery snippet collection]]></category>
		<category><![CDATA[jquery xml]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[sample functions]]></category>
		<category><![CDATA[snippet library]]></category>
		<category><![CDATA[snippets]]></category>

		<guid isPermaLink="false">http://addyosmani.com/blog/?p=422</guid>
		<description><![CDATA[&#160; &#160; In today&#8217;s post I&#8217;m going to show you guys 50 jQuery Snippets that can help you with your JavaScript projects. Some of these snippets are going to be things that have just been supported with jQuery 1.4.2 whilst others are really useful functions or methods that can help you do things better or [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://addyosmani.com/blog/50-jquery-snippets-for-developers/"><img width="530" height="342" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/03/snippets.jpg"  class="alignnone size-full wp-image-431" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>In today&#8217;s post I&#8217;m going to show you guys 50 jQuery Snippets that can help you with your JavaScript projects. Some of these snippets are going to be things that have just been supported with jQuery 1.4.2 whilst others are really useful functions or methods that can help you do things better or quicker. I&#8217;ve tried to bare in mind optimal performance with these snippets so if there&#8217;s anything you see that you think could be done better, please feel free to post your version in the comments!. I hope you find the post useful.</p>
<p><span id="more-422"></span></p>
<p>&nbsp;</p>
<p>
<style type="text/css">
  #tiplist { list-style-type: decimal; }</p>
</style>
<div>&nbsp;</div>
<ul id="tiplist">
<li>
<h2>How to Create A Nested Filter:</h2>
<pre name="code" class="javascript">
 //a filter allows you to reduce the set of matched elements
 //to those that match a given selector. In this case the query
 //removes anything which doesn't (:not) have (:has) a child with
 //class &quot;selected&quot; (.selected)

 .filter(&quot;:not(:has(.selected))&quot;)
</pre>
</li>
<li>
<h2>How to Reuse Your Element Searches</h2>
<pre name="code" class="html">
var allItems = $(&quot;div.item&quot;);
var keepList = $(&quot;div#container1 div.item&quot;);

//Now you can keep working with those jQuery objects. For example,
//trim down the &quot;keep list&quot; based on checkboxes whose names
//correspond to
<div>class names:

$(formToLookAt + &quot; input:checked&quot;).each(function() {     keepList = keepList.filter(&quot;.&quot; + $(this).attr(&quot;name&quot;)); });</div>
</pre>
</li>
<li>
<h2>How To Check If An Element contains a certain class or element with <i>has()</i>:</h2>
<pre name="code" class="javascript">

 //jQuery 1.4.* includes support for the has method. This method will find
 //if a an element contains a certain other element class or whatever it is
 //you are looking for and do anything you want to them.

 $(&quot;input&quot;).has(&quot;.email&quot;).addClass(&quot;email_icon&quot;);  
</pre>
</li>
<li>
<h2>How to Switch StyleSheets With jQuery:</h2>
<pre name="code" class="javascript">
	//Look for the media-type you wish to switch then set the href to your new style sheet
	$('link[media='screen']').attr('href', 'Alternative.css');</pre>
</li>
<li>
<h2>How to Limit the Scope of Selection (For Optimization):</h2>
<pre name="code" class="javascript">

		//Where possible, pre-fix your class names with a tag name
		//so that jQuery doesn't have to spend more time searching
		//for the element you're after. Also remember that anything
		//you can do to be more specific about where the element is
		//on your page will cut down on execution/search times

		var in_stock = $('#shopping_cart_items input.is_in_stock');
</pre>
<pre name="code" class="html">
<ul id="shopping_cart_items">
<li>
<input type="radio" value="Item-X" name="item" class="is_in_stock" /> Item X</li>
<li>
<input type="radio" value="Item-Y" name="item" class="3-5_days" /> Item Y</li>
<li>
<input type="radio" value="Item-Z" name="item" class="unknown" /> Item Z</li>
</ul>
</pre>
</li>
<li>
<h2>How to Correctly Use ToggleClass:</h2>
<pre name="code" class="javascript">

	 //Toggle class allows you to add or remove a class
	 //from an element depending on the presence of that
	 //class. Where some developers would use:

	 a.hasClass('blueButton') ? a.removeClass('blueButton') : a.addClass('blueButton');

	 //toggleClass allows you to easily do this using

	 a.toggleClass('blueButton');
</pre>
</li>
<li>
<h2>How to set an IE Specific Function:</h2>
<pre name="code" class="javascript">

	if ($.browser.msie) { // Internet Explorer is a sadist. }
</pre>
</li>
<li>
<h2>How to Replace an element with jQuery:</h2>
<pre name="code" class="javascript">
$('#thatdiv').replaceWith('fnuh');</pre>
</li>
<li>
<h2>How to Verify if an element is empty:</h2>
<pre name="code" class="javascript">
if ($('#keks').html()) { //Nothing found ;} </pre>
</li>
<li>
<h2>How to find out the index of an element in an unordered set</h2>
<pre name="code" class="javascript">
$(&quot;ul &gt; li&quot;).click(function () {
    var index = $(this).prevAll().length;
});</pre>
</li>
<li>
<h2>How to Bind a function to an event:</h2>
<pre name="code" class="javascript">
$('#foo').bind('click', function() {
  alert('User clicked on &quot;foo.&quot;');
});</pre>
</li>
<li>
<h2>How to Append or add HTML to an element:</h2>
<pre name="code" class="javascript">
$('#lal').append('sometext');</pre>
</li>
<li>
<h2>How to use an object literal to define properties when creating an element</h2>
<pre name="code" class="javascript">
	var e = $(&quot;&quot;, { href: &quot;#&quot;, class: &quot;a-class another-class&quot;, title: &quot;...&quot; });
	</pre>
</li>
<li>
<h2>How to Filter using multiple-attributes</h2>
<pre name="code" class="javascript">

	//This precision-based approached can be useful when you use
	//lots of similar input elements which have different types
	var elements = $('#someid input[type=sometype][value=somevalue]').get();
	</pre>
</li>
<li>
<h2>How to Preload images with jQuery:</h2>
<pre name="code" class="javascript">

	jQuery.preloadImages = function() { for(var i = 0; i').attr('src', arguments[i]); } };

	// Usage $.preloadImages('image1.gif', '/path/to/image2.png', 'some/image3.jpg');
	</pre>
</li>
<li>
<h2>How to set an event handler for any element that matches a selector:</h2>
<pre name="code" class="javascript">
$('button.someClass').live('click', someFunction);

	//Note that in jQuery 1.4.2, the delegate and undelegate options have been
	//introduced to replace live as they offer better support for context

    //For example, in terms of a table where before you would use..

	// .live()
	$(&quot;table&quot;).each(function(){
	  $(&quot;td&quot;, this).live(&quot;hover&quot;, function(){
		$(this).toggleClass(&quot;hover&quot;);
	  });
	});

	//Now use..

	$(&quot;table&quot;).delegate(&quot;td&quot;, &quot;hover&quot;, function(){
  $(this).toggleClass(&quot;hover&quot;);
});
</pre>
</li>
<li>
<h2>How to find an option element that&#8217;s been selected:</h2>
<pre name="code" class="javascript">
	$('#someElement').find('option:selected');
	</pre>
</li>
<li>
<h2>How to hide an element that contains text of a certain value:</h2>
<pre name="code" class="javascript">
$(&quot;p.value:contains('thetextvalue')&quot;).hide();</pre>
</li>
<li>
<h2>How To AutoScroll to a section of your page:</h2>
<pre name="code" class="javascript">
jQuery.fn.autoscroll = function(selector) {
  $('html,body').animate(
    {scrollTop: $(selector).offset().top},
    500
  );
}

//Then to scroll to the class/area you wish to get to like this:
$('.area_name').autoscroll();
</pre>
</li>
<li>
<h2>How To Detect Any Browser:</h2>
<pre name="code" class="javascript">
	Detect Safari (if( $.browser.safari)),
	Detect IE6 and over (if ($.browser.msie &amp;&amp; $.browser.version &gt; 6 )),
	Detect IE6 and below (if ($.browser.msie &amp;&amp; $.browser.version &lt;= 6 )),
	Detect FireFox 2 and above (if ($.browser.mozilla &amp;&amp; $.browser.version &gt;= '1.8' ))</pre>
</li>
<li>
<h2>How To Replace a word in a string:</h2>
<pre name="code" class="javascript">
var el = $('#id');
	el.html(el.html().replace(/word/ig, ''));</pre>
</li>
<li>
<h2>How To Disable right-click contextual menu :</h2>
<pre name="code" class="javascript">
$(document).bind('contextmenu',function(e){ return false; });</pre>
</li>
<li>
<h2>How to define a Custom Selector</h2>
<pre name="code" class="javascript">
	$.expr[':'].mycustomselector = function(element, index, meta, stack){
    // element- is a DOM element
    // index - the current loop index in stack
    // meta - meta data about your selector
    // stack - stack of all elements to loop

    // Return true to include current element
    // Return false to explude current element
};

// Custom Selector usage:
$('.someClasses:test').doSomething();
</pre>
</li>
<li>
<h2>How to check if an element exists</h2>
<pre name="code" class="javascript">
if ($('#someDiv').length) {//hooray!!! it exists...}</pre>
</li>
<li>
<h2>How to Detect Both Right &amp; Left Mouse-clicks with jQuery:</h2>
<pre name="code" class="javascript">
$(&quot;#someelement&quot;).live('click', function(e) {
    if( (!$.browser.msie &amp;&amp; e.button == 0) || ($.browser.msie &amp;&amp; e.button == 1) ) {
        alert(&quot;Left Mouse Button Clicked&quot;);
    }
    else if(e.button == 2)
        alert(&quot;Right Mouse Button Clicked&quot;);
});
</pre>
</li>
<li>
<h2>How To Show or Erase a Default Value In An Input Field:</h2>
<pre name="code" class="javascript">
//This snippet will show you how to keep a default value
//in a text input field for when a user hasn't entered in
//a value to replace it

swap_val = [];
$(&quot;.swap&quot;).each(function(i){
    swap_val[i] = $(this).val();
    $(this).focusin(function(){
        if ($(this).val() == swap_val[i]) {
            $(this).val(&quot;&quot;);
        }
    }).focusout(function(){
        if ($.trim($(this).val()) == &quot;&quot;) {
            $(this).val(swap_val[i]);
        }
    });
});
</pre>
<pre name="code" class="html">
<input type="text" value="Enter Username here.." class="swap" />
</pre>
</li>
<li>
<h2>How To Automatically Hide or Close Elements After An Amount Of Time (supports 1.4):</h2>
<pre name="code" class="javascript">

 //Here's how we used to do it in 1.3.2 using setTimeout
    setTimeout(function() {
  $('.mydiv').hide('blind', {}, 500)
}, 5000);

//And here's how you can do it with 1.4 using the delay() feature (this is a lot like sleep)
$(&quot;.mydiv&quot;).delay(5000).hide('blind', {}, 500);
 </pre>
</li>
<li>
<h2>How To Add Dynamically Created Elements to the DOM:</h2>
<pre name="code" class="javascript">
 var newDiv = $('');
	newDiv.attr('id','myNewDiv').appendTo('body'); </pre>
</li>
<li>
<h2>How To Limit The Number Of Characters in a &quot;Text-Area&quot; field:</h2>
<pre name="code" class="javascript">
	jQuery.fn.maxLength = function(max){
	this.each(function(){
		var type = this.tagName.toLowerCase();
		var inputType = this.type? this.type.toLowerCase() : null;
		if(type == &quot;input&quot; &amp;&amp; inputType == &quot;text&quot; || inputType == &quot;password&quot;){
			//Apply the standard maxLength
			this.maxLength = max;
		}
		else if(type == &quot;textarea&quot;){
			this.onkeypress = function(e){
				var ob = e || event;
				var keyCode = ob.keyCode;
				var hasSelection = document.selection? document.selection.createRange().text.length &gt; 0 : this.selectionStart != this.selectionEnd;
				return !(this.value.length &gt;= max &amp;&amp; (keyCode &gt; 50 || keyCode == 32 || keyCode == 0 || keyCode == 13) &amp;&amp; !ob.ctrlKey &amp;&amp; !ob.altKey &amp;&amp; !hasSelection);
			};
			this.onkeyup = function(){
				if(this.value.length &gt; max){
					this.value = this.value.substring(0,max);
				}
			};
		}
	});
};

//Usage:

$('#mytextarea').maxLength(500);
</pre>
</li>
<li>
<h2>How to create a basic test for a function</h2>
<pre name="code" class="javascript">

	//Separate tests into modules.
module(&quot;Module B&quot;);

test(&quot;some other test&quot;, function() {
  //Specify how many assertions are expected to run within a test.
  expect(2);
  //A comparison assertion, equivalent to JUnit's assertEquals.
  equals( true, false, &quot;failing test&quot; );
  equals( true, true, &quot;passing test&quot; );
});
</pre>
</li>
<li>
<h2>How to clone an element in jQuery:</h2>
<pre name="code" class="javascript">
var cloned = $('#somediv').clone(); </pre>
</li>
<li>
<h2>How to test if an element is visible in jQuery:</h2>
<pre name="code" class="javascript">
if($(element).is(':visible') == 'true') { //The element is Visible } </pre>
</li>
<li>
<h2>How to center an element on screen:</h2>
<pre name="code" class="javascript">
jQuery.fn.center = function () {
	this.css('position','absolute');
	this.css('top', ( $(window).height() - this.height() ) / +$(window).scrollTop() + 'px');
	this.css('left', ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + 'px');return this;}
	//Use the above function as: $(element).center(); </pre>
</li>
<li>
<h2>How to put the values of all the elements of a particular name into an array:</h2>
<pre name="code" class="javascript">

	var arrInputValues = new Array();
   $(&quot;input[name='table\\[\\]']&quot;).each(function(){
     arrInputValues.push($(this).val());
});
</pre>
</li>
<li>
<h2>How to Strip HTML From Your Element</h2>
<pre name="code" class="javascript">

	(function($) {
    $.fn.stripHtml = function() {
        var regexp = /&lt;(&quot;[^&quot;]*&quot;|'[^']*'|[^'&quot;&gt;])*&gt;/gi;
        this.each(function() {
            $(this).html(
                $(this).html().replace(regexp,&rdquo;&quot;)
            );
        });
        return $(this);
    }
})(jQuery); 

	//usage:
	$('p').stripHtml();  
</pre>
</li>
<li>
<h2>How to get a parent element using closest:</h2>
<pre name="code" class="javascript">
$('#searchBox').closest('div'); </pre>
</li>
<li>
<h2>How to log jQuery events using Firebug and Firefox:</h2>
<pre name="code" class="javascript">

// Allows chainable logging
// Usage: $('#someDiv').hide().log('div hidden').addClass('someClass');
jQuery.log = jQuery.fn.log = function (msg) {
      if (console){
         console.log(&quot;%s: %o&quot;, msg, this);
      }
      return this;
};
</pre>
</li>
<li>
<h2>How to force links to open in a pop-up window:</h2>
<pre name="code" class="javascript">

	jQuery('a.popup').live('click', function(){
	newwindow=window.open($(this).attr('href'),'','height=200,width=150');
	if (window.focus) {newwindow.focus()}
	return false;
});
</pre>
</li>
<li>
<h2>How to force links to open in a new tab:</h2>
<pre name="code" class="javascript">

jQuery('a.newTab').live('click', function(){
	newwindow=window.open($(this).href);
	jQuery(this).target = &quot;_blank&quot;;
	return false;
});
</pre>
</li>
<li>
<h2>How to select siblings in jQuery using .siblings()</h2>
<pre name="code" class="javascript">

// Rather than doing this
$('#nav li').click(function(){
    $('#nav li').removeClass('active');
    $(this).addClass('active');
});

// Do this instead
$('#nav li').click(function(){
    $(this).addClass('active')
        .siblings().removeClass('active');
});
	</pre>
</li>
<li>
<h2>How to Toggle All the checkboxes on a page:</h2>
<pre name="code" class="javascript">
var tog = false; // or true if they are checked on load
$('a').click(function() {
    $(&quot;input[type=checkbox]&quot;).attr(&quot;checked&quot;,!tog);
    tog = !tog;
});
</pre>
</li>
<li>
<h2>How to filter down a list of elements based on some input text:</h2>
<pre name="code" class="javascript">

	//If the value of the element matches that of the entered text
	//it will be returned
	$('.someClass').filter(function() {
    return $(this).attr('value') == $('input#someId').val() ;
 })
 </pre>
</li>
<li>
<h2>How to get mouse cursor X and Y</h2>
<pre name="code" class="javascript">
$(document).mousemove(function(e){
$(document).ready(function() {
$().mousemove(function(e){
$(&rsquo;#XY&rsquo;).html(&rdquo;X Axis : &rdquo; + e.pageX + &rdquo; | Y Axis &rdquo; + e.pageY);
});
});</pre>
</li>
<li>
<h2>How to make an entire List Element (LI) clickable</h2>
<pre name="code" class="javascript">
$(&quot;ul li&quot;).click(function(){
  window.location=$(this).find(&quot;a&quot;).attr(&quot;href&quot;); return false;
});
</pre>
<pre name="code" class="html">
<ul> 
<li><a href="#">Link 1</a></li>

 
<li><a href="#">Link 2</a></li>

 
<li><a href="#">Link 3</a></li>

	
<li><a href="#">Link 4</a></li>

</ul>
</pre>
</li>
<li>
<h2>How to Parse XML with jQuery (Basic example):</h2>
<pre name="code" class="javascript">
function parseXml(xml) {
	//find every Tutorial and print the author
	$(xml).find(&quot;Tutorial&quot;).each(function()
	{
	$(&quot;#output&quot;).append($(this).attr(&quot;author&quot;) + &quot;&quot;);
	});
}
</pre>
</li>
<li>
<h2>How to Check if an image has been fully loaded:</h2>
<pre name="code" class="javascript">

 $('#theImage').attr('src', 'image.jpg').load(function() {
alert('This Image Has Been Loaded');
});
</pre>
</li>
<li>
<h2>How to namespace events using jQuery:</h2>
<pre name="code" class="javascript">

//Events can be namespaced like this
$('input').bind('blur.validation', function(e){
    // ...
});

//The data method also accept namespaces
$('input').data('validation.isValid', true);
</pre>
</li>
<li>
<h2>How to Check if Cookies Are Enabled Or Not:</h2>
<pre name="code" class="javascript">
    var dt = new Date();
    dt.setSeconds(dt.getSeconds() + 60);
    document.cookie = &quot;cookietest=1; expires=&quot; + dt.toGMTString();
    var cookiesEnabled = document.cookie.indexOf(&quot;cookietest=&quot;) != -1;
    if(!cookiesEnabled)
	{
        //cookies have not been enabled
    }
</pre>
</li>
<li>
<h2>How to Expire A Cookie:</h2>
<pre name="code" class="javascript">
var date = new Date();
date.setTime(date.getTime() + (x * 60 * 1000));
$.cookie('example', 'foo', { expires: date });
</pre>
</li>
<li>
<h2>Replace any URL on your page with a clickable link</h2>
<pre name="code" class="javascript">
$.fn.replaceUrl = function() {
        var regexp = /((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&amp;%@!\-\/]))?)/gi;
        this.each(function() {
            $(this).html(
                $(this).html().replace(regexp,'<a href="$1">$1</a>&lsquo;)
            );
        });
        return $(this);
    }  

	//usage

	$('p').replaceUrl();
</pre>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://addyosmani.com/blog/50-jquery-snippets-for-developers/feed/</wfw:commentRss>
		<slash:comments>56</slash:comments>
		</item>
		<item>
		<title>jQuery Fubar &#8211; How To Create A Website Toolbar From Scratch And Add Widgets To It</title>
		<link>http://addyosmani.com/blog/jquery-fubar-how-to-create-a-website-toolbar-from-scratch-and-add-widgets-to-it/</link>
		<comments>http://addyosmani.com/blog/jquery-fubar-how-to-create-a-website-toolbar-from-scratch-and-add-widgets-to-it/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 16:53:45 +0000</pubDate>
		<dc:creator>Addy</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[addyosmani.com]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[fan page]]></category>
		<category><![CDATA[fixed position toolbar]]></category>
		<category><![CDATA[fixed-position]]></category>
		<category><![CDATA[footer]]></category>
		<category><![CDATA[footer bar]]></category>
		<category><![CDATA[footer toolbar]]></category>
		<category><![CDATA[fubar sitebar]]></category>
		<category><![CDATA[fubar toolbar]]></category>
		<category><![CDATA[google buzz]]></category>
		<category><![CDATA[javascript fixed position toolbar]]></category>
		<category><![CDATA[javascript toolbar]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery fixed-position css toolbar]]></category>
		<category><![CDATA[jquery fubar]]></category>
		<category><![CDATA[jquery plugins]]></category>
		<category><![CDATA[jquery toolbar]]></category>
		<category><![CDATA[jquery toolbar for your website]]></category>
		<category><![CDATA[jquery ui]]></category>
		<category><![CDATA[meebo bar]]></category>
		<category><![CDATA[meebo website bar]]></category>
		<category><![CDATA[mysitebar]]></category>
		<category><![CDATA[prettyphoto]]></category>
		<category><![CDATA[sitebar]]></category>
		<category><![CDATA[toolbar]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[website bar]]></category>
		<category><![CDATA[website bottom bar]]></category>
		<category><![CDATA[website footer bar]]></category>
		<category><![CDATA[website sharing]]></category>
		<category><![CDATA[website sharing bar]]></category>
		<category><![CDATA[website social bar]]></category>
		<category><![CDATA[website toolbar]]></category>
		<category><![CDATA[wibiya]]></category>
		<category><![CDATA[widgets]]></category>

		<guid isPermaLink="false">http://addyosmani.com/blog/jquery-fubar-how-to-create-a-website-toolbar-from-scratch-and-add-widgets-to-it/</guid>
		<description><![CDATA[&#160; Over the past year, we&#8217;ve seen website toolbar&#8217;s become an increasingly popular way for site-owners to offer users a consistent set of powerful social features, regardless of what page they&#8217;re on &#8211; Share, Subscribe, Tweet, Talk &#8211; you name it and chances are there&#8217;s a toolbar out there that offers some variation of these [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://addyosmani.com/blog/jquery-fubar-how-to-create-a-website-toolbar-from-scratch-and-add-widgets-to-it/#myPosts"><img width="530" height="342" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/02/fubars.jpg" alt="fubars" style="border-width: 0px; display: inline;" title="fubars" /></a></p>
<p>&nbsp;</p>
<p>Over the past year, we&#8217;ve seen website toolbar&#8217;s become an increasingly popular way for site-owners to offer users a consistent set of powerful social features, regardless of what page they&#8217;re on &#8211; Share, Subscribe, Tweet, Talk &#8211; you name it and chances are there&#8217;s a toolbar out there that offers some variation of these features. Facebook were one of the first companies to introduce this toolbar concept and have been the source of inspiration for many others.&nbsp;</p>
<p>&nbsp;</p>
<p>Taking a leaf from their book, companies like <a href="http://www.wibiya.com">Wibiya</a> and <a href="http://www.meebo.com">Meebo</a> have been at the forefront of a toolbar-for-the masses revolution, offering easily customizable widgets for almost anyone to install on their pages. Larger companies have also been hopping onto the toolbar-band too, with sites like <a href="http://www.cnet.com">CNET.com</a> embracing this concept as a way to offer their visitors more ways to interact with their site.</p>
<p>&nbsp;</p>
<p>In today&#8217;s post, I&#8217;m going to show you how to create your <i>very own</i> jQuery-powered website toolbar and then we&#8217;re going to pack it full of lots of useful widget features such as those found in the Wibiya-toolbar &ndash; I call it <a href="http://addyosmani.com/resources/sitebar/final-alt.html">jQuery Fubar</a>.</p>
<p>&nbsp;</p>
<p><span id="more-411"></span></p>
<p><b><font size="4">What Site-bars Are Out There At The Moment?</font></b></p>
<p>&nbsp;</p>
<p>As I mentioned, we&rsquo;ve all seen the widget-packed Wibiya Toolbar in action and they&rsquo;ve recently moved from their invite-only model to being fully open to the public. Meebo (the popular web destination for online IM services) also started offering their own version of this toolbar and both of them offer something a little different (Meebo for example includes a pretty funky drag-and-share feature). Today, we&rsquo;ve going to create our very own awesome website toolbar, but from a design perspective here&rsquo;s how the Meebo and Wibiya bars look close-up.</p>
<p>&nbsp;</p>
<p><strong>Wibiya</strong></p>
<p>&nbsp;</p>
<p><a href="http://addyosmani.com/blog/wp-content/uploads/2010/02/image1.png" class="thickbox"><img width="484" height="48" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/02/image_thumb.png" alt="image" style="border-width: 0px; display: block; float: none; margin-left: auto; margin-right: auto;" title="image" /></a>&nbsp;</p>
<p><strong>Meebo </strong></p>
<p>&nbsp;</p>
<p><a href="http://addyosmani.com/blog/wp-content/uploads/2010/02/image2.png" class="thickbox"><img width="488" height="45" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/02/image_thumb1.png" alt="image" style="border-width: 0px; display: block; float: none; margin-left: auto; margin-right: auto;" title="image" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Now that we know what we&rsquo;re aiming for, let&rsquo;s see how easy it can be to put together something like this ourselves.</p>
<p>&nbsp;</p>
<p><img width="545" height="342" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/02/fubar_part1.jpg" alt="fubar_part1" style="border-width: 0px; display: block; float: none; margin-left: auto; margin-right: auto;" title="fubar_part1" /></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><b><font size="4">The First Step &ndash; Fixed Positioning with CSS</font></b></p>
<p><b>     <br />
</b></p>
<p>The first step in creating a website-toolbar is creating an empty div which can be correctly fixed-positioned at the bottom of any webpage. The HTML for this is:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">&lt;div id<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;content&quot;</span><span style="color: #00AA00;">&gt;</span>&amp;nbsp<span style="color: #00AA00;">;</span>&lt;/div<span style="color: #00AA00;">&gt;</span>
&nbsp;
&lt;div id<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;floatingbar&quot;</span><span style="color: #00AA00;">&gt;</span>&lt;ul<span style="color: #00AA00;">&gt;</span> &lt;li<span style="color: #00AA00;">&gt;</span>&lt;a href<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;#&quot;</span><span style="color: #00AA00;">&gt;</span>Item name&lt;/a<span style="color: #00AA00;">&gt;</span>&lt;/li<span style="color: #00AA00;">&gt;</span> &lt;br /<span style="color: #00AA00;">&gt;</span>&lt;li<span style="color: #00AA00;">&gt;</span>&lt;a href<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;#&quot;</span><span style="color: #00AA00;">&gt;</span>Item name&lt;/a<span style="color: #00AA00;">&gt;</span>&lt;/li<span style="color: #00AA00;">&gt;</span> &lt;br /<span style="color: #00AA00;">&gt;</span>&lt;li<span style="color: #00AA00;">&gt;</span>&lt;a href<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;#&quot;</span><span style="color: #00AA00;">&gt;</span>Item name&lt;/a<span style="color: #00AA00;">&gt;</span>&lt;/li<span style="color: #00AA00;">&gt;</span> &lt;br /<span style="color: #00AA00;">&gt;</span>&lt;li<span style="color: #00AA00;">&gt;</span>&lt;a href<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;#&quot;</span><span style="color: #00AA00;">&gt;</span>Item name&lt;/a<span style="color: #00AA00;">&gt;</span>&lt;/li<span style="color: #00AA00;">&gt;</span> &lt;br /<span style="color: #00AA00;">&gt;</span>&lt;/ul<span style="color: #00AA00;">&gt;</span>&lt;/div<span style="color: #00AA00;">&gt;</span></pre></div></div>

<p>&nbsp;</p>
<p>and the CSS for this can be found below.</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">  div<span style="color: #cc00cc;">#floatingbar</span>
    <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;"><span style="color: #cc66cc;">100</span>%</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>	
    <span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #a1a100;">@media screen</span>
  <span style="color: #00AA00;">&#123;</span>
  body&amp;gt<span style="color: #00AA00;">;</span>div<span style="color: #cc00cc;">#floatingbar</span>
    <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">fixed</span><span style="color: #00AA00;">;</span>
    <span style="color: #00AA00;">&#125;</span>
  <span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>&nbsp;</p>
<p>Whilst fixed-positioning isn&#8217;t very difficult to achieve using browsers like FireFox and Chrome, it&#8217;s been notoriously buggy to code for Internet Explorer 6. Thankfully TagSoup came up with <a href="http://tagsoup.com/cookbook/css/fixed/">this</a> wonderful set of CSS/JS hackswhich claim to support fixed-positioning all the way back to IE5. If you&#8217;re creating a toolbar from scratch, I would definitely recommend reading their post as it&#8217;ll save you a lot of time later on. The IE Fix for this is:</p>
<p>&nbsp;</p>
<p><b>JavaScript/HTML:</b></p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;css/fixed4ie.css&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>onload = function() { 
content.focus() }
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></td></tr></table></div>

<p><b>CSS:</b></p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">body
  <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;"><span style="color: #cc66cc;">100</span>%</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;"><span style="color: #cc66cc;">100</span>%</span><span style="color: #00AA00;">;</span>
  <span style="color: #00AA00;">&#125;</span>
div<span style="color: #cc00cc;">#content</span>
  <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;"><span style="color: #cc66cc;">100</span>%</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;"><span style="color: #cc66cc;">100</span>%</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
  <span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>&nbsp;</p>
<p><b><font size="4">Once you&#8217;ve got your basic-toolbar in place&hellip;</font></b></p>
<p><b>     <br />
</b></p>
<p>The next thing you&#8217;re going to want to do is begin adding in some basic styling around it. Most website-toolbars are around the same dimension in height (although there is no official &ldquo;standard&rdquo;) so I&#8217;m going to set the height of my component as well as some very basic skinning and CSS to style my list items. The background design is made possible with a blue gradient PNG that has some light shadows added to it &#8211; similar to the kind of design Wibiya have gone for. Although CSS3 could be just as equally used to create this effect, remember that some people still use IE!</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">div<span style="color: #cc00cc;">#floatingbar</span>
    <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;"><span style="color: #cc66cc;">100</span>%</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">38px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span>Arial<span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'../images/tui.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>	
    <span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#floatingbar</span> ul <span style="color: #00AA00;">&#123;</span> 
<span style="color: #000000; font-weight: bold;">list-style-type</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#floatingbar</span> ul li 
<span style="color: #00AA00;">&#123;</span> 
<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">14px</span><span style="color: #00AA00;">;</span> 
<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#666</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">-3px</span><span style="color: #00AA00;">;</span>  
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#floatingbar</span> ul li a 
<span style="color: #00AA00;">&#123;</span> 
<span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> 
<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>  
<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">12px</span><span style="color: #00AA00;">;</span>  <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">normal</span><span style="color: #00AA00;">;</span> 
<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span>Arial<span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#floatingbar</span> ul li a<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#000033</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>&nbsp;</p>
<p>Now that this is done, I also want to add some basic animation to my toolbar so that when users first load up their page, the bar will slide up from the bottom. This is made possible using jQuery&#8217;s great animate() feature by keeping the initial height of the component at 0 and then tweening it up to it&#8217;s maximum height over a period of time. The code for this can be found below</p>
<p>&nbsp;</p>
<p><b>CSS:</b></p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">div<span style="color: #cc00cc;">#floatingbar</span>
    <span style="color: #00AA00;">&#123;</span>  
    <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>	
    <span style="color: #00AA00;">&#125;</span></pre></div></div>

<p><b>JavaScript:</b></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">'text/javascript'</span><span style="color: #339933;">&gt;</span> 
  $<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
  $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#floatingbar'</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>height<span style="color: #339933;">:</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> height<span style="color: #339933;">:</span> <span style="color: #3366CC;">'38'</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'slow'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>&nbsp;</p>
<p>This will end up creating something a little like <a href="http://addyosmani.com/resources/sitebar/step1.html">this</a></p>
<p>&nbsp;</p>
<p>
<b><font size="4">Next, populate the toolbar with some links and some more jQuery Magic</font> </b></p>
<p><b>     <br />
</b></p>
<p>In the next step of development, we&rsquo;re going to add some nice visual effects to the toolbar, with the assistance of two of my favorite jQuery plugins &ndash; the first will provide us with some lightweight tooltips for our toolbar items whilst the second is going to be used for displaying our content.</p>
<p>&nbsp;</p>
<p><a name="Details">1.<b> jQuery Tipsy Tooltips </b>for Toolbar Elements &#8211; This is a plugin used for adding Facebook-Like Tooltip effects to your site or links (</a><a href="http://onehackoranother.com/projects/jquery/tipsy/">http://onehackoranother.com/projects/jquery/tipsy/</a>)</p>
<p>&nbsp;</p>
<p><strong>Sample Usage:</strong></p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">'text/javascript'</span><span style="color: #339933;">&gt;</span> 
  $<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
  $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.toolbarLink'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">tipsy</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>gravity<span style="color: #339933;">:</span> <span style="color: #3366CC;">'s'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>&nbsp;</p>
<p>2.<b> jQuery PrettyPhoto </b>- This is a lightbox alternative that allows you to display any type of content, in particular, iFrame content from local or external websites (<a href="http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lightbox-clone/" title="http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lightbox-clone/">http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lightbox-clone/</a>)</p>
<p>&nbsp;</p>
<p><strong>Sample Usage:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> charset<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;utf-8&quot;</span><span style="color: #339933;">&gt;</span>
  $<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.gallery a[rel^='prettyPhoto']&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">prettyPhoto</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>theme<span style="color: #339933;">:</span><span style="color: #3366CC;">'facebook'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>&nbsp;</p>
<p>&nbsp;</p>
<p><b><font size="4">Let&#8217;s start adding some social features to the toolbar</font></b></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><img width="520" height="401" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/02/addingos.jpg" alt="addingos" style="border-width: 0px; display: block; float: none; margin-left: auto; margin-right: auto;" title="addingos" /></p>
<p><b>     <br />
</b></p>
<p>When I first looked at the Wibiya toolbar, the big features that appealed to me were how easy it made it for any user to interact with all of the social networks associated with a website. I could easily take a look at the site&#8217;s Twitter account or become a fan of their Facebook Fan page, I could even easily browse through all their pictures without having to leave the page I was on. That &quot;ease&quot; of access impressed me, so I developed my website toolbar with widgets in mind.</p>
<p>&nbsp;</p>
<p>When there are so many different ways currently available to pull in your recent tweets or display your Flickr albums in an easily scrollable box, why not find an implementation you like and just customize it?. So, that&#8217;s what we&#8217;re going to do.</p>
<p>&nbsp;</p>
<p>1. <b>Google Buzz Plugin</b> &#8211; Mike More&#8217;s excellent Google Buzz Widget grabs the feed of your latest Google Buzz posts and refreshes this list depending on a set of parameters you&#8217;ve configured (<a href="http://www.moretechtips.net/2010/02/google-buzz-widget-jquery-plugin.html">http://www.moretechtips.net/2010/02/google-buzz-widget-jquery-plugin.html</a>)</p>
<p>&nbsp;</p>
<p>2. <b>Sea of Clouds jQuery Twitter Plugin</b> &#8211; This wonderfully compact plugin makes pulling your Twitter feeds a piece of cake and also allows you to customize the output quite extensively (<a href="http://tweet.seaofclouds.com/">http://tweet.seaofclouds.com/</a>)</p>
<p>&nbsp;</p>
<p>3. <b>Facebook Fan Page Widget </b>- The Facebook Fan Page Widget is a widget provided free by Facebook to site owners wishing to share their fan streams or followers in a box on their website. To allow you to show to Fan Box widgets side by side as in the original Wibiya bar, one can either choose to proxy one of the content boxes or load each of the widgets in separate iFrames which are then loaded into the same window.</p>
<p>&nbsp;</p>
<p>4. <b>Coolris Express Viewer -</b> CoolIris offer the public a <a href="http://www.cooliris.com/express">free</a> version of their commercial 3D-Wall Component for use on your own personal sites. They&#8217;ve got a fantastic widget generator online that lets you pull in feeds from all sorts of sources including Flickr, YouTube or your own RSS Feed. It then takes this information and renders it as a scrollable wall of thumbnails that&#8217;s easy to view.</p>
<p>&nbsp;</p>
<p>5. <b>AddToAny Subscription and Share Widgets</b> &#8211; These excellent widgets allow you to configure everything down to the event handlers that execute them so you can choose whether they appear on click or on mouse over. All the usual share sites and social networks are included and these guys even offer an API to anyone wishing to do more with their code.</p>
<p>&nbsp;</p>
<p>6. <b>ConveyThis.com Translation Features</b> &#8211; Google Translate has been a favorite service among many of my fellow coders for a while now, but I came across this great service that allows you to give your visitors the choice to pick what translation service they want to use to translate your page once they&#8217;ve selected a language. Because some services have stronger features in one area of language than others, your visitors will have all the options they could want available to them. ConveyThis<a href="http://code.google.com/p/jquery-sitebar/w/edit/ConveyThis">?</a> also has a great widget you can add easily to your site, so definitely check it out.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><b><font size="4">Widget Delivery</font></b></p>
<p><b>     <br />
</b></p>
<p>Widgets (or plugins such as a Twitter-Reader or Translation service) can be delivered to our visitors through the site-bar in two main methods. The first is on page-load and the second is dynamically on-demand. The second of these options is the most beneficial as it means that we only have to load up the plugin when a user requests it. This can be either done through Ajax-Calls or iFrames.</p>
<p>&nbsp;</p>
<p>In my implementation I have opted for iFrames through the PrettyPhoto Light-Box plugin &#8211; I thought this was a good idea because it provides a nice sandboxed area where the widget can execute as required without the chance of it interfering with the other widgets on the page. Whilst this isn&#8217;t a problem for most modern browsers, sandboxing widgets into iFrames can help lower the bug rate for older browsers like IE6.</p>
<p>&nbsp;</p>
<p>To host a widget inside a lightbox iFrame, all you need to do is write or paste the code for it, once configured, into a new html file, save it into a local file in your toolbar directory and call it via PrettyPhoto as follows:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;prettyPhoto[iframe]&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;widget.html&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Here's the tooltip text &quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;toolbarLink&quot;</span>&gt;</span> My Page<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span></pre></td></tr></table></div>

<p>&nbsp;</p>
<p>You can then freely call any widget file, with it&rsquo;s very own themes if desired the same way you would any other link used from a lightbox. prettyPhoto also includes some pagination by default so if you want to easily flick through all of the widgets available on your toolbar you can do so through the controls at the bottom of the lightbox.</p>
<p>&nbsp;</p>
<p><font size="4"><strong>Further Customization &amp; Demos</strong></font></p>
<p>&nbsp;</p>
<p>It&rsquo;s possible to further customize your toolbar by adding in icons next to each of your widget links and floating them accordingly. For the example in today&rsquo;s post, I&rsquo;ve used some fantastic 24&#215;24 icons from <a href="http://www.iconfinder.net">iconfinder.net</a>, and you can see the final version of this page <a href="http://addyosmani.com/resources/sitebar/final-basic.html">here</a> (or click below to expand the screenshot).</p>
<p>&nbsp;</p>
<p><a href="http://addyosmani.com/blog/wp-content/uploads/2010/02/image3.png" class="thickbox"><img width="508" height="244" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/02/image_thumb2.png" alt="image" style="border-width: 0px; display: block; float: none; margin-left: auto; margin-right: auto;" title="image" /></a></p>
<p>&nbsp;</p>
<p>You can also take your imagination one step further and replace all of the text in your toolbar with some nice images &ndash; I personally spent a few minutes putting together some gradient text in PhotoShop and <a href="http://addyosmani.com/resources/sitebar/final-alt.html">here&rsquo;s</a> what the final product looked like.</p>
<p>&nbsp;</p>
<p><a href="http://addyosmani.com/blog/wp-content/uploads/2010/02/image4.png" class="thickbox"><img width="510" height="243" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/02/image_thumb3.png" alt="image" style="border-width: 0px; display: block; float: none; margin-left: auto; margin-right: auto;" title="image" /></a></p>
<p>&nbsp;</p>
<p>With a little more work you could easily add some nice toggle buttons to the side of the toolbar to allow visitors to open or close it and there are a lot more widgets out there that you could experiment adding to your version.</p>
<p>&nbsp;</p>
<p>and that&rsquo;s it!. If you found today&rsquo;s tutorial helpful, let me know in the comments section below.</p>
<p>&nbsp;</p>
<p><strong><font size="4">Download All Of Todays Examples</font></strong></p>
<p>&nbsp;</p>
<p>You can download all of today&rsquo;s examples including both the CSS/Icons version of Fubar as well as the Graphics version from the link below. All widgets can be obtained or generated from the site&rsquo;s referenced in the list earlier in the article, but I&rsquo;m also including my own ones in the example pack so you can see how easy it is to get setup.</p>
<p>&nbsp;</p>
<p><a href="http://jquery-sitebar.googlecode.com/files/sitebar.rc1.zip"><img width="240" height="77" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/02/dlbutton.jpg" alt="dlbutton" style="border-width: 0px; display: block; float: none; margin-left: auto; margin-right: auto;" title="dlbutton" /></a>&nbsp;</p>
<p>&nbsp;</p>
<p><strong><font size="4">Bonus: Fixed-Position Website Toolbar Plugins</font></strong></p>
<p>&nbsp;</p>
<p>As a bonus to today&rsquo;s post, I&rsquo;m also sharing some of the best out-of-the-box alternative solutions and tutorials available for creating your own customized fixed-position Site Bar. We all know that Wibiya is great for a one-click solution, but if you need something a little different one of these will definitely be able to help if the tutorial above doesn&rsquo;t give you what you&rsquo;re after.</p>
<p>&nbsp;</p>
<p><strong><a href="http://www.pvmgarage.com/en/2009/12/nice-and-simple-toolbar-for-your-website-with-css3-and-jquery/">CSS3 Fixed-Position Toolbar for your site with Social Networking Icons</a></strong></p>
<p>&nbsp;</p>
<p><a href="http://www.pvmgarage.com/en/2009/12/nice-and-simple-toolbar-for-your-website-with-css3-and-jquery/"><img width="532" height="227" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/02/image5.png" alt="image" style="border-width: 0px; display: block; float: none; margin-left: auto; margin-right: auto;" title="image" /></a></p>
<p>&nbsp;</p>
<p>Learn how to create a fantastic fixed footer toolbar for your site &ndash; this version includes some usefully placed social networking and subscription icons, great eye-candy tooltip effects and a complete tutorial on how to create it from start to finish. CSS3 Effects compliment it further with some nice visual design touches. Recommended for those who aren&rsquo;t looking for extensive changes in customization to the above design and currently have more of a functionality requirement.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="http://www.sohtanaka.com/web-design/examples/footer-panel/"><strong>Facebook Style Footer-Toolbar from Soh Tanaka</strong></a></p>
<p>&nbsp;</p>
<p><a href="http://www.sohtanaka.com/web-design/examples/footer-panel/"><img width="535" height="215" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/02/image6.png" alt="image" style="border-width: 0px; display: block; float: none; margin-left: auto; margin-right: auto;" title="image" /></a></p>
<p>&nbsp;</p>
<p>Soh Tanaka presents this excellent tutorial on how to create a Facebook Style Fixed Site Footer toolbar. This implementation is very close to how the real Facebook site-bar looks and feels and even includes a follow-up tutorial on how to create a pop-out Friends List Chat bar. Recommended for those looking for a fully-featured example of how to create a floating site toolbar for further customization.</p>
<p>&nbsp;</p>
<p><strong><a href="http://www.bennadel.com/blog/1740-Building-A-Fixed-Position-Bottom-Menu-Bar-ala-FaceBook-.htm">Floating Footer Toolbar</a></strong></p>
<p>&nbsp;</p>
<p><a href="http://www.bennadel.com/blog/1740-Building-A-Fixed-Position-Bottom-Menu-Bar-ala-FaceBook-.htm"><img width="515" height="238" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/02/image7.png" alt="image" style="border-width: 0px; display: block; float: none; margin-left: auto; margin-right: auto;" title="image" /></a></p>
<p>&nbsp;</p>
<p>This entry from Ben Nadel, the most barebones of my recommended tutorials for today, will show you how to build a very very simple implementation of a floating site toolbar. This doesn&rsquo;t include any of the sample icons or buttons that Soh Tanaka&rsquo;s version above does so if you want an example that you can literally just start adding your own content to, this would be the one to get.&nbsp; Ben&rsquo;s version has been tested with many browsers including IE6, so cross browser compatibility won&rsquo;t be an issue!.</p>
<p>&nbsp;</p>
<p><strong>J<a href="http://ryan.rawswift.com/sandbox/jixedbar-0.0.2/demo/">ixedBar &ndash; A Fixed-Position Toolbar plugin for jQuery</a></strong></p>
<p>&nbsp;</p>
<p><a href="http://ryan.rawswift.com/sandbox/jixedbar-0.0.2/demo/"><img width="511" height="212" border="0" src="http://addyosmani.com/blog/wp-content/uploads/2010/02/image8.png" alt="image" style="border-width: 0px; display: block; float: none; margin-left: auto; margin-right: auto;" title="image" /></a></p>
<p>&nbsp;</p>
<p>Here&rsquo;s a recently updated plugin that takes a lot out of the effort out of creating a fixed-position toolbar for your site. All you need to do is create a &lt;ul&gt; /&lt;li&gt; structure for each split section and then have the plugin transform it into the toolbar for you. It&rsquo;s a hassle-free way of adding this feature to your projects and at under 7KB, it&rsquo;s definitely a recommended download.</p>
]]></content:encoded>
			<wfw:commentRss>http://addyosmani.com/blog/jquery-fubar-how-to-create-a-website-toolbar-from-scratch-and-add-widgets-to-it/feed/</wfw:commentRss>
		<slash:comments>52</slash:comments>
		</item>
	</channel>
</rss>
