<?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"
	>

<channel>
	<title>Developer Tutorials' Webmaster Blog &#187; cache</title>
	<atom:link href="http://www.developertutorials.com/blog/tag/cache/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.developertutorials.com/blog</link>
	<description>Keeping webmasters up-to-date on technology.</description>
	<pubDate>Tue, 02 Sep 2008 14:59:45 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
	<language>en</language>
			<item>
		<title>Designing and Coding a Wordpress Theme From Scratch (Part 5)</title>
		<link>http://www.developertutorials.com/blog/javascript/designing-and-coding-a-wordpress-theme-from-scratch-part-5-149/</link>
		<comments>http://www.developertutorials.com/blog/javascript/designing-and-coding-a-wordpress-theme-from-scratch-part-5-149/#comments</comments>
		<pubDate>Tue, 29 Apr 2008 04:48:59 +0000</pubDate>
		<dc:creator>JonGos</dc:creator>
		
		<category><![CDATA[Design]]></category>

		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[Photoshop]]></category>

		<category><![CDATA[WordPress]]></category>

		<category><![CDATA[cache]]></category>

		<category><![CDATA[css]]></category>

		<category><![CDATA[markup]]></category>

		<category><![CDATA[photoshop]]></category>

		<category><![CDATA[psd]]></category>

		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://www.developertutorials.com/blog/javascript/designing-and-coding-a-wordpress-theme-from-scratch-part-5-149/</guid>
		<description><![CDATA[Going From Photoshop to XHTML to Wordpress Theme.  In this multi-part series I'll detail how to create and design a Wordpress theme in Photoshop and take it from just an idea to fully coded.
]]></description>
			<content:encoded><![CDATA[<p><a target="_blank" href="http://www.developertutorials.com/blog/design/designing-and-coding-a-wordpress-theme-from-scratch-part-4-147/">Image heavy websites</a> have one problem: load time.  So if you&#8217;re designing a Wordpress theme that relies heavily on images like one made in Photoshop, you want to do everything you can to increase speed.  a) You want the images to display as shortly after the text does as possible and b) you want to do everything to help users on slower connections.</p>
<p>One way to do this is with <a href="http://www.designcodeexecute.com/2008/04/09/javascript-preload-images-script/" target="_blank">javascript</a>, the other way is with <a href="http://www.netmechanic.com/news/vol6/css_no18.htm" target="_blank">CSS</a>.</p>
<p><span id="more-149"></span></p>
<p><b>Preloading Images with Javascript</b></p>
<p>Javascript is unfortunately abused all over the web.  It&#8217;s used for scripts that create pop-up ads, pop-under ads, and to change browser homepages.  So the only draw back to this approach is that some users have deliberately turned off javascript in their browsers to thwart abusers.  No big deal.  If the user has javascript turned off, the technique I&#8217;m about to share will be ignored and the page will load normally.</p>
<ol>
<li>So how is it done? In the folder that contains your index.html file and stylesheets, create a folder called &#8216;Scripts&#8217;. </li>
<li>Let&#8217;s create a blank document in the text editor and call it <strong>preload.js</strong></li>
<li>We&#8217;re going to create an array of calls for images that will start to load as soon as the head of the page loads.  List all the images you want to have &#8216;headstart&#8217; on loading here.  This can include images that are linked to on the page but that don&#8217;t appear on the page.  When dealing with a Photoshop design that is being marked up to XHTML you should place all the slices here.</li>
<li>Next you want to place the following code in the header section of your HTML document just after the &lt;title&gt; and &lt;meta&gt; tags.
<pre>
&lt;script type="text/javascript" src="scripts/preload.js"&gt; &lt;/script&gt;
</pre>
<p>This tells the HTML document to look for the script before the stylesheet and subsequently, to request the array of images the stylesheet needs to load.  Alternatively you could place the javascript inline but I prefer using external documents.
</li>
<li>The contents of the Javascript file should look like this:
<pre>
if (document.images)
{
preload_image = new Image();
img_path = new Array();	

   img1 = new Image();
   img2 = new Image();
   img3 = new Image();
   img4 = new Image();
   img5 = new Image();
   img6 = new Image();
   img7 = new Image();
   img8 = new Image();
   img9 = new Image();
   img10 = new Image();
   img11 = new Image();
   img12 = new Image();
   img1 = new Image();
   img1.src = "../images/yourimage_01.png";
   img2.src = "../images/yourimage_02.png";
   img3.src = "../images/yourimage_03.png";
   img4.src = "../images/yourimage_04.png";
   img5.src = "../images/yourimage_05.png";
   img6.src = "../images/yourimage_06.png";
   img7.src = "../images/yourimage_07.png";
   img8.src = "../images/yourimage_08.png";
   img9.src = "../images/yourimage_09.png";
   img10.src = "../images/yourimage_10.png";
   img11.src = "../images/yourimage_11.png";
   img12.src = "../images/yourimage_12.png";
   img13.src = "../image/yourimage_13.png";

for(var i = 0; i&lt;=img_path.length; i++)
preload_image.src = img_path[i];
}
</pre>
</li>
<li>That&#8217;s it.  You can use this to preload images for the next page, icons, or any number of things but the idea is to use it to call the array before they&#8217;re called elsewhere on the page.</li>
</ol>
<p><b>Preloading Images with CSS</b></p>
<p>Another method is to preload images in the stylesheet.  This method is fairly useless on the actual homepage but it can be used to preload all sorts of images on subsequent pages.  Lets look at the code:</p>
<pre>
     .hiddenPic {display:none;}
</pre>
<p>This class should be placed somewhere in your stylesheet.  You can place it inline in your html document and it would look like this:</p>
<pre>
     &lt;style type="text/css"&gt;
     .hiddenPic {display:none;}
     &lt;/style&gt;
</pre>
<p>Next, at the <strong>bottom</strong> of your html page just before the &lt;/body&gt; closing tag, we need to call all the images from the next page we want preloaded and apply the <strong>.hiddenPic</strong> class:</p>
<pre>
     &lt;img src="yourimage.jpg" alt="" title="" height="" width="" class="hiddenPic"&gt;

     &lt;img src="yourimage01.jpg" alt="" title="" height="" width="" class="hiddenPic"&gt;

     &lt;img src="yourimage02.jpg" alt="" title="" height="" width="" class="hiddenPic"&gt;

&lt;/body&gt;
</pre>
<p>How does it work?  Essentially you&#8217;re calling the images when the browser reads the page and hiding them before they are ever displayed with the <strong>display:none;</strong> line.  The idea is that the browser downloads the images and caches them anyways so that when the user clicks through to the next page the users browser will note that the images being requested have already been cached and won&#8217;t waste time downloading them again.</p>
<p>Now that load time has been reduced, in Part 6 we&#8217;ll get back to marking up our XHTML to PHP and developing our Wordpress theme.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark" style="float:left;">
<div class="d149" style="overflow:hidden">
<div id="socialstyles"><a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.developertutorials.com/blog/javascript/designing-and-coding-a-wordpress-theme-from-scratch-part-5-149/&amp;title=Designing+and+Coding+a+Wordpress+Theme+From+Scratch+%28Part+5%29" title="Add to&nbsp;Del.icio.us">Del.icio.us</a></div><div id="socialstyles"><a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.developertutorials.com/blog/javascript/designing-and-coding-a-wordpress-theme-from-scratch-part-5-149/&amp;title=Designing+and+Coding+a+Wordpress+Theme+From+Scratch+%28Part+5%29" title="Add to&nbsp;Digg This">Digg This</a></div><div id="socialstyles"><a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.developertutorials.com/blog/javascript/designing-and-coding-a-wordpress-theme-from-scratch-part-5-149/&amp;title=Designing+and+Coding+a+Wordpress+Theme+From+Scratch+%28Part+5%29" title="Add to&nbsp;Stumble">Stumble</a></div></div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.developertutorials.com/blog/javascript/designing-and-coding-a-wordpress-theme-from-scratch-part-5-149/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
