<?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>Kirsten Jahn on Design &#38; Life &#187; Code Samples</title>
	<atom:link href="http://www.kirstenjahn.com/blog/category/code-samples/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kirstenjahn.com/blog</link>
	<description>A design &#38; life blog.</description>
	<lastBuildDate>Wed, 24 Nov 2010 22:00:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>MIX10: Jason Weber&#8217;s High-Performance Best Practices for Web Sites</title>
		<link>http://www.kirstenjahn.com/blog/2010/04/mix10-jason-webers-high-performance-best-practices-for-web-sites/</link>
		<comments>http://www.kirstenjahn.com/blog/2010/04/mix10-jason-webers-high-performance-best-practices-for-web-sites/#comments</comments>
		<pubDate>Mon, 05 Apr 2010 14:42:31 +0000</pubDate>
		<dc:creator>Kirsten</dc:creator>
				<category><![CDATA[Code Samples]]></category>
		<category><![CDATA[Design Talk]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[websites]]></category>

		<guid isPermaLink="false">http://www.kirstenjahn.com/blog/?p=244</guid>
		<description><![CDATA[During a long car trip to Buffalo, NY I decided to enrich myself by watching a few videos having to do with the field of web design. Here are my notes on Jason Weber&#8217;s presentation on High-Performance Best Practices for &#8230; <a href="http://www.kirstenjahn.com/blog/2010/04/mix10-jason-webers-high-performance-best-practices-for-web-sites/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-medium wp-image-255" title="screen-shot-2010-04-05-at-110524-am" src="http://www.kirstenjahn.com/blog/wp-content/uploads/2010/04/screen-shot-2010-04-05-at-110524-am-300x188.png" alt="screen-shot-2010-04-05-at-110524-am" width="300" height="188" />During a long car trip to Buffalo, NY I decided to enrich myself by watching a few videos having to do with the field of web design. Here are my notes on Jason Weber&#8217;s presentation on High-Performance Best Practices for Web Sites. Below are his &#8220;20&#8243; best practices for performance:</p>
<h3>NETWORKING</h3>
<ol>
<li> Compress files downloads.<br />
Utilize gzip encoding when making http requests and responding to those requests. Don&#8217;t do it on images! They&#8217;re already compressed.</li>
<li> Provide cache-able content.<br />
Set an expiration date on your responses so the server doesn&#8217;t have to pull it down again.</li>
<li> Use conditional requests.<br />
Only pull content if it was last modified since a certain date. Include the modification date in the response.</li>
<li> Minify your Javascript.<br />
Removes extra spaces and returns, replaces variables with single characters, can make your Javascript be 25% of its original size.</li>
<li> Do not scale images.<br />
Requires less CPU time for the browser to display the image. Sending more data than what is needed slows down the download process.</li>
<li> Use image sprites! <img src='http://www.kirstenjahn.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /><br />
Keeps network requests down.</li>
</ol>
<p><span id="more-244"></span></p>
<h3>HTML</h3>
<ol>
<li> Link Javascript to the bottom of your page.Inline Javascript slows down your page load in older browsers b/c older browsers need to execute that code right away.<br />
Don&#8217;t ever link to a script file in the head of your page. In older browsers they will go ahead and load that Javascript before the page is even done loading. Link your Javascript at the end of the file instead.</li>
<li> Add a defer tag when you must link Javascript at the top of the page.You can also use the defer tag in the script tag if you must put your Javascript in the head part of your page. This defers the loading of the Javascript until the entire HTML page has been rendered (supported since IE4, don&#8217;t know about FF).</li>
</ol>
<h3>CSS</h3>
<ol>
<li> Link the CSS in the head of your file, unlike the Javascript best practice.Don&#8217;t want any &#8220;flashes of unstyled content.&#8221; Avoid embedded styles; can slow down loading of webpages.</li>
<li> Avoid using the @import for CSS files as it slows down the browser.The browser tries to download all of those imported files so it can properly render the cascade and thus takes longer.</li>
</ol>
<h3>COLLECTIONS</h3>
<ol>
<li> He didn&#8217;t really address anything under this topic.</li>
</ol>
<h3>JAVASCRIPT</h3>
<ol>
<li> Minimize symbol resolution (walking up the lookup chain).To resolve a variable value there are 3 places Javascript looks:Local &gt; Intermediate Scopes &gt; GlobalThe higher up it must go to get the value the more performance cost.Objects work in the same way:Instance &gt; Prototype Chain &gt; DOMIf you don&#8217;t declare the variable using var = its scope is global and costs you performance. If you use var = you scope it to be a local variable.
<p>Works the same way with functions too.</li>
<li> Use native methods.To parse JSON you can use the native parse or stringify that&#8217;s native to the browser (possibly only IE8 though&#8230;?).</li>
<li> Remove duplicate script files.</li>
<li> Minimize the amount of Javascript frameworks you use on a page.</li>
</ol>
<h3>MARSHALLING</h3>
<ol>
<li> Minimize the amount of DOM interactions that you make from Javascript.Each time the Javascript engine has to communicate with the DOM it costs you a little bit more.<br />
Cache your DOM lookups in a variable, e.g. var elms = document.body.all;</li>
</ol>
<h3>DOM</h3>
<ol>
<li> Built in methods are always more effecient than trying to roll something yourself.Instead of nodes[i] to iterate through just use the DOM API node.nextSibling; to iterate through that collection; minimizes calls to the DOM.</li>
<li> Use the selectors API for effecient access to collections (IE8+ only).</li>
</ol>
<h3>FORMATTING</h3>
<ol>
<li> Only send the required styles for that page.(Doesn&#8217;t this go against the whole cacheing of your stylesheet as an advantage while surfing through your site?)</li>
<li> When possible, use class or id based selectors over element selectors.Make element selectors as simple as possible and use child or descendent selectors when able.</li>
</ol>
<h3>BLOCK BUILDING, LAYOUT, RENDERING</h3>
<ol>
<li> Batch visual changes.Don&#8217;t allow your user to see every change you make to the page until you&#8217;re done. Put all changes in a variable and then change the page.</li>
</ol>
<p>At the end of Mr. Weber&#8217;s presentation he hit briefly on the new features of IE9. Below are my notes on this topic:</p>
<ul>
<li> Hardware accelerated HTML 5</li>
<li> Compiled Javascript (into native machine code to be executed rather than interpreting non-native machine code)</li>
<li> GPU powered HTML5 graphics</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.kirstenjahn.com/blog/2010/04/mix10-jason-webers-high-performance-best-practices-for-web-sites/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Disable Submit Button Until Checkbox is Checked</title>
		<link>http://www.kirstenjahn.com/blog/2010/01/disable-sumit-button-until-checkbox-is-checked/</link>
		<comments>http://www.kirstenjahn.com/blog/2010/01/disable-sumit-button-until-checkbox-is-checked/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 19:06:35 +0000</pubDate>
		<dc:creator>Kirsten</dc:creator>
				<category><![CDATA[Code Samples]]></category>
		<category><![CDATA[checkbox]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[submit]]></category>

		<guid isPermaLink="false">http://www.kirstenjahn.com/blog/?p=206</guid>
		<description><![CDATA[Here&#8217;s an interesting tidbit of code I worked out today for a client website: $(document).ready(function() { $('input.button').attr('disabled', true); $('input.button').attr('value', 'Please accept our terms to submit'); $('.accept input').bind('click', function() { if ($('.accept input').is(':checked') == true) { $('input.button').removeAttr('disabled'); $('input.button').attr('value', 'Send Memory'); } &#8230; <a href="http://www.kirstenjahn.com/blog/2010/01/disable-sumit-button-until-checkbox-is-checked/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s an interesting tidbit of code I worked out today for a client website:</p>
<p><code class="js">$(document).ready(function() {<br />
$('input.button').attr('disabled', true);<br />
$('input.button').attr('value', 'Please accept our terms to submit');<br />
$('.accept input').bind('click', function() {<br />
if ($('.accept input').is(':checked') == true) {<br />
$('input.button').removeAttr('disabled');<br />
$('input.button').attr('value', 'Send Memory');<br />
} else {<br />
$('input.button').attr('disabled', true);<br />
$('input.button').attr('value', 'Please accept our terms to submit');<br />
}<br />
});<br />
});</code></p>
<p>It&#8217;s JQuery for disabling a submit button until a checkbox is checked. In addition, as an added usability feature, the button says &#8220;Please accept our terms to submit&#8221; so that the user knows why the button isn&#8217;t able to be clicked.</p>
<p>In this example &#8220;button&#8221; is the class of my button and my terms checkbox is wrapped in a span with a class of &#8220;accept&#8221; (had to work around ASP.NET here at work thank you).</p>
<p>This post will most definitely be useful if I ever look for this functionality again!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kirstenjahn.com/blog/2010/01/disable-sumit-button-until-checkbox-is-checked/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Clearfix Method</title>
		<link>http://www.kirstenjahn.com/blog/2009/10/clearfix-method/</link>
		<comments>http://www.kirstenjahn.com/blog/2009/10/clearfix-method/#comments</comments>
		<pubDate>Fri, 09 Oct 2009 18:57:52 +0000</pubDate>
		<dc:creator>Kirsten</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Code Samples]]></category>
		<category><![CDATA[background]]></category>
		<category><![CDATA[clearfix]]></category>
		<category><![CDATA[float]]></category>

		<guid isPermaLink="false">http://www.kirstenjahn.com/rants/?p=118</guid>
		<description><![CDATA[The eternal question for beginning web designers often is, &#8220;How do I get my background image/color to fill all the way down the page when I float two divs next to each other?&#8221; Enter &#8220;clearfix.&#8221; I first learned about the &#8230; <a href="http://www.kirstenjahn.com/blog/2009/10/clearfix-method/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The eternal question for beginning web designers often is, &#8220;How do I get my background image/color to fill all the way down the page when I float two divs next to each other?&#8221;</p>
<p>Enter &#8220;clearfix.&#8221;</p>
<p>I first learned about the clearfix method by reading the book &#8220;Stylin&#8217; with CSS: A Designer&#8217;s Guide&#8221; (1st Edition) by Charles Wyke-Smith, now in its 2nd edition (<a href="http://www.amazon.com/Stylin-CSS-Designers-Guide-2nd/dp/0321525566/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1255114238&amp;sr=8-1" target="_blank">See it on Amazon</a>).</p>
<p>When you float two items next to each other (say a nav bar and a content area) the two divs collapse in height because floated elements have no height. Say you then try to set a background to the div containing both your nav bar and content area. What happens? A whole lot of nothing. Why? Because the containing div is wrapping two divs that have no height themselves, so what makes you think your container div is going to have a height?</p>
<p>To fix this problem simply put the class of &#8220;clearfix&#8221; on the containing div and copy and paste the following into your CSS file.</p>
<p><code class="css">/* CLEARFIX CONTROLS --------------------------------------------------- */<br />
.clearfix:after {content:"."; display:block; height:0; clear:both; visibility:hidden;}<br />
.clearfix {display: inline-block;}   /* a fix for IE Mac */<br />
/* next a fix for the dreaded Guillotine bug in IE6 */<br />
/* Hides from IE-mac \*/<br />
* html .clearfix {height: 1%;}<br />
.clearfix {display: block;}<br />
/* End hide from IE-mac */<br />
/* end of "no-extra-markup" clearing method */</code></p>
<p>Now I believe I have seen some Javascript fixes out there as well but why get involved with scripts when this is just as easy, if not easier? Besides, in my opinion, if you can do it elegantly with CSS you should really stay away from another Javascript call on your page.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kirstenjahn.com/blog/2009/10/clearfix-method/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Basics</title>
		<link>http://www.kirstenjahn.com/blog/2009/10/the-basics/</link>
		<comments>http://www.kirstenjahn.com/blog/2009/10/the-basics/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 20:27:45 +0000</pubDate>
		<dc:creator>Kirsten</dc:creator>
				<category><![CDATA[Code Samples]]></category>
		<category><![CDATA[favicon]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[stylesheet]]></category>

		<guid isPermaLink="false">http://www.kirstenjahn.com/rants/?p=99</guid>
		<description><![CDATA[A large part of this blog is to be a helpful resource for me as a web designer and front-end programmer. How so? Because every time I wrangle an entire day of anguish over a silly coding problem I intend &#8230; <a href="http://www.kirstenjahn.com/blog/2009/10/the-basics/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A large part of this blog is to be a helpful resource for me as a web designer and front-end programmer. How so? Because every time I wrangle an entire day of anguish over a silly coding problem I intend to post it here. That way I will have my very own resource to look back at! And maybe, just maybe, along the way, it will be helpful to <strong>you</strong> too!</p>
<p>Let&#8217;s start with the basics in my file here at work:</p>
<p><em>To link to a stylesheet:</em><br />
<code class="html">&lt;link href="PATHTOFILE.css" type="text/css" rel="stylesheet" media="MEDIA" /&gt;</code></p>
<p>&#8220;PATHTOFILE.css&#8221; is obviously the path to your CSS file, whether relative or absolute. &#8220;MEDIA&#8221; is what type of media your stylesheet addresses. Options include &#8220;screen&#8221; for viewing on a normal computer, &#8220;print&#8221; for when a user prints out your web site, and &#8220;handheld&#8221; for viewing on a mobile device.</p>
<p><em>To link to a javascript file:</em><br />
<code class="html">&lt;script src="PATHTOFILE.js" language="javascript" type="text/javascript"&gt;&lt;/script&gt;</code></p>
<p>&#8220;PATHTOFILE.js&#8221; is the path to your Javascript file, whether relative or absolute.</p>
<p><em>To link to a favicon:</em><br />
<code class="html">&lt;link href="PATHTOFILE.ico" rel="shortcut icon"/&gt;</code></p>
<p>&#8220;PATHTOFILE.ico&#8221; is the path to your favicon file, whether relative or absolute.</p>
<p><em>A JQuery ready command:</em><br />
<code class="js">$(document).ready(function(){<br />
});</code></p>
<p>This is the most basic JQuery command in which you stuff all other JQuery code into. It basically says &#8220;don&#8217;t run any of the code in here until the page is fully loaded, or &#8216;ready&#8217;.&#8221;</p>
<p>We&#8217;ll get more complex later, I <strong>promise</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kirstenjahn.com/blog/2009/10/the-basics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

