<?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>MR Forbes, Creative Web Developer</title>
	<atom:link href="http://www.mrforbes.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mrforbes.com</link>
	<description>Home of MR Forbes, Creative Web Developer</description>
	<lastBuildDate>Wed, 07 Oct 2009 20:09:17 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Fading PNGs in Internet Explorer 7 and 8</title>
		<link>http://www.mrforbes.com/thoughts/2009/10/07/fading-pngs-in-internet-explorer-7-and-8/</link>
		<comments>http://www.mrforbes.com/thoughts/2009/10/07/fading-pngs-in-internet-explorer-7-and-8/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 20:08:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Internet Explorer Hacks]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[ie]]></category>

		<guid isPermaLink="false">http://www.mrforbes.com/?p=166</guid>
		<description><![CDATA[How to get rid of that annoying black background on PNGs that change opacity in IE8]]></description>
			<content:encoded><![CDATA[<p>One issue I recently came across was the desire to use PNGs as the background of a tooltip, and to fade the tooltip in and out of view (you can see the functionality <a href="http://catalog.bocajava.com/coffee/coffee">here</a> by hovering over 'details' or clicking on 'buy now').  In case you haven't tried this before - IE7 and IE8 generally do not react well to fading PNGs, putting a black background under the portions of the PNG which have alpha transparency - and generally making the element look less than ideal.</p>
<p>Luckily, there is a fairly easy workaround for this situation as long as you are not trying to do too much with the pngs.  It will even fix pngs in IE6 for you too (in fact, that is the real purpose of the script).   That workaround is the jQuery ifixpng2 plugin, written by Yereth and available <a href="http://plugins.jquery.com/project/iFixPng2">here</a>.</p>
<p>All you need to do is install the plugin and use it on the PNG containing objects (images or backgrounds) that you would like to fade.  There are two changes you will need to make however:</p>
<p>Line 64 looks like this:</p>
<pre class="php">ltie7	: $.browser.msie &amp;&amp; $.browser.version &lt; <span style="color: #cc66cc;">7</span></pre>
<p>You'll want to change the 7 to a 9 (in hopes that this is fixed for good by IE 9, otherwise you'll need to go back and change it to 10 later).</p>
<p>The other change you need to make is on Line 149, which looks like this:</p>
<pre class="php">&nbsp;
<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>prop in expr<span style="color: #66cc66;">&#41;</span> elem.style.setExpression<span style="color: #66cc66;">&#40;</span>prop, expr<span style="color: #66cc66;">&#91;</span>prop<span style="color: #66cc66;">&#93;</span>, <span style="color: #ff0000;">'JavaScript'</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<p>Internet Explorer 8 doesn't support setExpression, so it will throw an error, unless you add an if statement to keep it from running:</p>
<pre class="php">&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> $.browser.msie &amp;&amp; $.browser.version &lt; <span style="color: #cc66cc;">8</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>prop in expr<span style="color: #66cc66;">&#41;</span> elem.style.setExpression<span style="color: #66cc66;">&#40;</span>prop, expr<span style="color: #66cc66;">&#91;</span>prop<span style="color: #66cc66;">&#93;</span>, <span style="color: #ff0000;">'JavaScript'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p>That's all there is to it.  Happy fading!</p>
]]></content:encoded>
			<wfw:commentRss>http://js-kit.com/rss/www.mrforbes.com/p=166</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting Up a Local Code Igniter Dev Environment (OSX)</title>
		<link>http://www.mrforbes.com/thoughts/2009/02/11/setting-up-a-local-code-igniter-dev-environment-osx/</link>
		<comments>http://www.mrforbes.com/thoughts/2009/02/11/setting-up-a-local-code-igniter-dev-environment-osx/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 20:37:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[tutorials]]></category>
		<category><![CDATA[code igniter]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.mrforbes.com/?p=153</guid>
		<description><![CDATA[Where I explain how to prepare a locally developed Code Igniter application.]]></description>
			<content:encoded><![CDATA[<p>I'm planning to write a tutorial on using jquery and Code Igniter to create some ajaxy / jsonp goodness.  In the process, I downloaded the latest version of CI and began setting it up - when I realized the setup may be helpful to describe.</p>
<p>While this tutorial is geared towards Mac users, most of the steps should be similar for Windows users.</p>
<h2>Step 1</h2>
<h3>Download and Install MAMP</h3>
<p><a title="MAMP" href="http://www.mamp.info/en/index.html">MAMP</a> is the OSX version of the one-click Apache-MySQL-PHP install.  If you're on a PC, you want to try out <a href="http://www.apachefriends.org/en/xampp.html">XAMPP</a> instead (XAMPP also comes in an OSX flavor, but I haven't personally tried it).  In any case, you'll want to download one of these two programs and follow the instructions for installation.</p>
<h2>Step 2</h2>
<h3>Download Code Igniter</h3>
<p>Code Igniter is an MVC based PHP framework created by the makers of Expression Engine - a CMS/blogging platform.  What (I think) sets CI apart from other frameworks like Cake or Zend is its soft learning curve and strong documentation.  The involved community doesn't hurt either.  You'll want to <a href="http://codeigniter.com/">download it</a> in order to continue to step 3.</p>
<h2>Step 3</h2>
<h3>Install Code Igniter</h3>
<p>Once you've downloaded and unzipped CI, you'll want to copy the folder over to your server root.  If you're using MAMP - the default is /Applications/MAMP/htdocs.  At that point, you should change the folder name from CodeIgniter_1.7.1 to whatever you want to use to describe your site.  I changed my folder name to 'ci'.   That's it for installation.</p>
<h2>Step 4</h2>
<h3>Setup Your MySQL database</h3>
<p>Odds are, you're following this tutorial so you can build a dynamic site in PHP.  Dynamic nearly always means database, so you'll have to create one.  You can do this in MAMP by switching over to your running instance and clicking on 'Open start page'.  From the links on top, you can select 'phpMyAdmin'.  Otherwise, you can probably just copy and paste this: http://localhost:8888/MAMP/frame.php?src=%2FphpMyAdmin%2F%3Flang%3Den-iso-8859-1&language=English.  From there, create a new database (I've called mine 'ci').  </p>
<p>A note here:  CI can handle sessions either with or without the database.  My personal preference is to use the database, because it provides greater functionality, and you don't have to worry about hitting your 4k cookie size limit.  Enabling database sessions is fairly simple in CI, and we'll get to that further down.  However, you'll first need to add the sessions table to the database.  The default name of the sessions table is 'ci_sessions'  - you can change this here and in the settings, but remember to do it in both places or this won't work.  In this case, I'm going to keep it the same.  Code Igniter provides the SQL you'll need here, so you can click on the 'SQL' tab in phpMyAdmin and copy/paste the code in.  Here it is:</p>
<pre class="sql">&nbsp;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #993333; font-weight: bold;">IF</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">EXISTS</span>  <span style="color: #ff0000;">`ci_sessions`</span> <span style="color: #66cc66;">&#40;</span>
session_id varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">40</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">'0'</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,
ip_address varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">16</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">'0'</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,
user_agent varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,
last_activity int<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #cc66cc;">0</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,
user_data text <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,
<span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #66cc66;">&#40;</span>session_id<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<h2>Step 5</h2>
<h3>Edit your Code Igniter Settings</h3>
<p>From this point, you'll want to edit your CI settings to match your environment.  The first thing we'll do is open up the system->application->config folder.  In here are all the files that run the configuration settings.  </p>
<h4>config.php</h4>
<p>On line 14, you'll see this:</p>
<pre class="php">&nbsp;
<span style="color: #0000ff;">$config</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'base_url'</span><span style="color: #66cc66;">&#93;</span>	= <span style="color: #ff0000;">&quot;http://example.com/&quot;</span>;
&nbsp;</pre>
<p>You'll want to change it to your own install directory.  You can also edit your vhosts file to have it match your live url... but that's a more advanced procedure and not part of this tutorial. So in this case, I've changed it to:</p>
<pre class="php">&nbsp;
<span style="color: #0000ff;">$config</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'base_url'</span><span style="color: #66cc66;">&#93;</span>	= <span style="color: #ff0000;">&quot;http://localhost:8888/ci/&quot;</span>;
&nbsp;</pre>
<p>The next portion of code you might need to change is from lines 234-242, and it looks like this:</p>
<pre class="php">&nbsp;
<span style="color: #0000ff;">$config</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'sess_cookie_name'</span><span style="color: #66cc66;">&#93;</span>		= <span style="color: #ff0000;">'ci_session'</span>;
<span style="color: #0000ff;">$config</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'sess_expiration'</span><span style="color: #66cc66;">&#93;</span>		= <span style="color: #cc66cc;">7200</span>;
<span style="color: #0000ff;">$config</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'sess_encrypt_cookie'</span><span style="color: #66cc66;">&#93;</span>	= <span style="color: #000000; font-weight: bold;">FALSE</span>;
<span style="color: #0000ff;">$config</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'sess_use_database'</span><span style="color: #66cc66;">&#93;</span>	= <span style="color: #000000; font-weight: bold;">FALSE</span>;
<span style="color: #0000ff;">$config</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'sess_table_name'</span><span style="color: #66cc66;">&#93;</span>		= <span style="color: #ff0000;">'ci_sessions'</span>;
<span style="color: #0000ff;">$config</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'sess_match_ip'</span><span style="color: #66cc66;">&#93;</span>		= <span style="color: #000000; font-weight: bold;">FALSE</span>;
<span style="color: #0000ff;">$config</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'sess_match_useragent'</span><span style="color: #66cc66;">&#93;</span>	= <span style="color: #000000; font-weight: bold;">TRUE</span>;
<span style="color: #0000ff;">$config</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'sess_time_to_update'</span><span style="color: #66cc66;">&#93;</span> 	= <span style="color: #cc66cc;">300</span>;
&nbsp;</pre>
<p>This is where you can setup your sessions to use the database, as outlined above.  Just change $config['sess_use_database'] to true.</p>
<p>There are other settings in config.php you can modify to suit the framework to your needs, but those are the only ones I typically use.</p>
<h4>database.php</h4>
<p>This is the file where we'll set our database access - location, username, password, and database name.  It looks like this:</p>
<pre class="php">&nbsp;
<span style="color: #0000ff;">$active_group</span> = <span style="color: #ff0000;">&quot;default&quot;</span>;
<span style="color: #0000ff;">$active_record</span> = <span style="color: #000000; font-weight: bold;">TRUE</span>;
&nbsp;
<span style="color: #0000ff;">$db</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'default'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'hostname'</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">&quot;localhost:8889&quot;</span>;
<span style="color: #0000ff;">$db</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'default'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'username'</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">&quot;root&quot;</span>;
<span style="color: #0000ff;">$db</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'default'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'password'</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">&quot;root&quot;</span>;
<span style="color: #0000ff;">$db</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'default'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'database'</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">&quot;ci&quot;</span>;
<span style="color: #0000ff;">$db</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'default'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'dbdriver'</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">&quot;mysql&quot;</span>;
<span style="color: #0000ff;">$db</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'default'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'dbprefix'</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">&quot;&quot;</span>;
<span style="color: #0000ff;">$db</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'default'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'pconnect'</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #000000; font-weight: bold;">TRUE</span>;
<span style="color: #0000ff;">$db</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'default'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'db_debug'</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #000000; font-weight: bold;">TRUE</span>;
<span style="color: #0000ff;">$db</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'default'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'cache_on'</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #000000; font-weight: bold;">FALSE</span>;
<span style="color: #0000ff;">$db</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'default'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'cachedir'</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">&quot;&quot;</span>;
<span style="color: #0000ff;">$db</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'default'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'char_set'</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">&quot;utf8&quot;</span>;
<span style="color: #0000ff;">$db</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'default'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'dbcollat'</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">&quot;utf8_general_ci&quot;</span>;
&nbsp;</pre>
<p>MAMP automatically sets your username and password to root, and your MySQL port to 8889, so can copy and paste the above for working locally.  You can also create a second set of these variables called $db['production'] for example, with your live settings in it.  When you are ready to move the site, all you'll need to do is change your $active_group variable to 'production'.</p>
<h4>autoload.php</h4>
<p>Code Igniter gives you the ability to add only the libraries and functionality you need for your project.  The autoload.php file lets you name which files you want across the application.  You can read more about it on the CI site, but one thing you'll likely want to do right away is enable your database and session libraries to load.  This is done on line 42:</p>
<pre class="php">&nbsp;
<span style="color: #0000ff;">$autoload</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'libraries'</span><span style="color: #66cc66;">&#93;</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'database'</span>,<span style="color: #ff0000;">'session'</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<p>Odds are you'll also want to load the URL helper, that allows you to enter shortcut functions for some common locations (like the base url).  You can do this on line 54:</p>
<pre class="php">&nbsp;
<span style="color: #0000ff;">$autoload</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'helper'</span><span style="color: #66cc66;">&#93;</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'url'</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<h4>.htaccess</h4>
<p>CI doesn't come with an .htaccess file, but odds are you'll want to add additional folders to your root 'ci' folder while keeping the rest of your site secure by redirecting most requests through the main index.php file.  So, create a file named .htaccess in your main 'ci' folder.  Within it, you'll want to do this:</p>
<pre>
RewriteEngine on
RewriteCond $1 !^(index\.php?|images|css|js)
RewriteRule ^(.*)$ http://localhost:8888/ci/index.php?/$1 [L]
</pre>
<p>What this does in tell the Apache URL-rewrite module to redirect any request that isn't in the above list to the index.php file of our 'ci' directory.  I've added images,css, and js folders to the 'ci' directory so I can start adding assets there.  When you want to link to your files, you'll be able to do so like this:</p>
<pre class="php">&nbsp;
&lt;img src=<span style="color: #ff0000;">&quot;&lt;?=base_url()?&gt;images/xxxxxxx.jpg&quot;</span> /&gt;
&nbsp;</pre>
<p>That's all there is to it.  At this point, you should have all of the basic resources you need to start developing a sweet app in Code Igniter.  When you are ready to move your site to a production server, just remember to change your database settings, base url in config.php, and the RewriteRule in your .htaccess file, and you'll be up and running in no time.</p>
]]></content:encoded>
			<wfw:commentRss>http://js-kit.com/rss/www.mrforbes.com/p=153</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>A Quick Code Igniter and JQuery Ajax Tutorial</title>
		<link>http://www.mrforbes.com/thoughts/2009/01/28/a-quick-code-igniter-and-jquery-ajax-tutorial/</link>
		<comments>http://www.mrforbes.com/thoughts/2009/01/28/a-quick-code-igniter-and-jquery-ajax-tutorial/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 04:18:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[code igniter]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.mrforbes.com/?p=138</guid>
		<description><![CDATA[Where I explain how to use the Code Igniter php framework and jquery to do some ajax. Re-post of 8/07 article.]]></description>
			<content:encoded><![CDATA[<div class="alert" style="margin-bottom:10px;">
this is a re-post of an August, 2007 article from my old site.  It's still generating a lot of traffic, so I didn't want all of the users who may be looking for it to lose access.</div>
<p><em>This tutorial assumes a basic working knowledge of Code Igniter.  If you have never used CI before, please refer to the <a href="http://codeigniter.com/user_guide/">framework documentation</a></em></p>
<p>In the old days (2 years ago), working the Javascript magic to create a cool AJAX based event took a fairly decent working knowledge of the mechanisms behind the process.  With the increasing popularity of Javascript libraries however, this type of functionality became available to the web site hobbyist, and was made much easier for the web site professional.</p>
<p>The following step-by-step tutorial will show you how to combine the power of <a href="http://www.jquery.com">JQuery</a> (a javascript library that weighs in at about 20k) with <a href="http://www.codeigniter.com">Code Igniter</a> (a PHP framework based on the MVC design pattern) to quickly and painlessly pass a record ID through the javascript and over to the server, where it will be passed to a mysql database, used to retrieve some data, and sent back to the page for display.</p>
<p><strong>Step 1</strong><br />
We begin by assuming that you have a div with an id of content, which is where you would like your freshly retrieved data to display, once it has been freshly retrieved.  For this exercise, you have already taken an action to call your javascript function with a record ID parameter. </p>
<p>The first thing you need to do, is make sure JQuery is being loaded, and to create a function for your AJAX request.</p>
<pre class="php">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;script language</span>=<span style="color: #ff0000;">&quot;javascript&quot;</span> src=<span style="color: #ff0000;">&quot;/path_to_jquery/jquery.js&quot;</span> &gt;&lt;/script&gt;
<span style="color: #000000; font-weight: bold;">&lt;script language</span>=<span style="color: #ff0000;">&quot;javascript&quot;</span>&gt;
 <span style="color: #000000; font-weight: bold;">function</span> get_record_id<span style="color: #66cc66;">&#40;</span>record_id<span style="color: #66cc66;">&#41;</span> 
     <span style="color: #66cc66;">&#123;</span>
     <span style="color: #66cc66;">&#125;</span>
<span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span>
&nbsp;</pre>
<p><strong>Step 2:</strong><br />
Next, youll use the JQuery function load, and attach it to your content div:</p>
<pre class="php">&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> get_record_id<span style="color: #66cc66;">&#40;</span>record_id<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
     $<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'#content'</span><span style="color: #66cc66;">&#41;</span>.load<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p><strong>Step 3:</strong><br />
The load function accepts three arguments.  The page to be called on the other side of the HTTPRequest, the array to pass through the POST, and a callback function.  It looks like this:</p>
<pre class="php">&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> get_record_id<span style="color: #66cc66;">&#40;</span>record_id<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
     $<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'#content'</span><span style="color: #66cc66;">&#41;</span>.load<span style="color: #66cc66;">&#40;</span>/controller/method,p,<span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>str<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
&nbsp;
	 <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p>Lets go back to that.  Code Igniter URLs are created by calling the name of your controller, followed by the function inside the controller class that will handle your request.  If your server does not support mod-rewrite, you may also need to append an index.php to the beginning.  The str inside the callback function is the results of your AJAX request.  There isnt much use for the str when using the .load function, but it does come in handy using the other JQuery AJAX functions - $.post and $.get, which I assume are self explanatory.</p>
<p><strong>Step 4</strong></p>
<pre class="php">&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> p = <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>; <span style="color: #808080; font-style: italic;">//instantiate the array</span>
p<span style="color: #66cc66;">&#91;</span>record_id<span style="color: #66cc66;">&#93;</span> = record_id <span style="color: #808080; font-style: italic;">//assign your record_id variable to it.</span>
&nbsp;</pre>
<p>Thats all there is to it.  Your final javascript function looks like this:</p>
<pre class="php">&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> get_record_id<span style="color: #66cc66;">&#40;</span>record_id<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
     <span style="color: #000000; font-weight: bold;">var</span> p = <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>;
     p<span style="color: #66cc66;">&#91;</span>record_id<span style="color: #66cc66;">&#93;</span> = record_id
     $<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'#content'</span><span style="color: #66cc66;">&#41;</span>.load<span style="color: #66cc66;">&#40;</span>/controller/method,p,<span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>str<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
&nbsp;
     <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p><strong>Step 5</strong><br />
On the CI side, you have a controller and method setup something like this:</p>
<pre class="php">&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> Controller
<span style="color: #66cc66;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">function</span> Controller<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
   <span style="color: #66cc66;">&#123;</span>
       parent::<span style="color: #006600;">CI</span>;
   <span style="color: #66cc66;">&#125;</span>
&nbsp;
   <span style="color: #000000; font-weight: bold;">function</span> method<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
   <span style="color: #66cc66;">&#123;</span>
   <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p>The important part is the method() function, as it will contain some of the code we need to make things happen.</p>
<p><strong>Step 6</strong><br />
The first thing you need to do on the CI side is retrieve the value passed through the request object.  This is simple enough, using $_POST[record_id].  You also want to load up your database model so you can get the record out of your database.  So, well load the database library, and then load the actual model.  Then, we want to send the record ID to the database, get the resulting data, and pass it back out to the request.  our function starts to look like its doing something useful pretty quickly.</p>
<pre class="php">&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> method<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
   <span style="color: #0000ff;">$record_id</span> = <span style="color: #0000ff;">$_POST</span><span style="color: #66cc66;">&#91;</span>record_id<span style="color: #66cc66;">&#93;</span>;
   <span style="color: #808080; font-style: italic;">//set the record ID</span>
   <span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">load</span>-&gt;<span style="color: #006600;">library</span><span style="color: #66cc66;">&#40;</span>database<span style="color: #66cc66;">&#41;</span>;
   <span style="color: #808080; font-style: italic;">//load the database library to connect to your database</span>
   <span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">load</span>-&gt;<span style="color: #006600;">model</span><span style="color: #66cc66;">&#40;</span>records<span style="color: #66cc66;">&#41;</span>;
   <span style="color: #808080; font-style: italic;">//inside your system/application/models folder, create a model based on the procedure</span>
   <span style="color: #808080; font-style: italic;">//outlined in the CI documentation</span>
   <span style="color: #0000ff;">$results</span> = <span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">records</span>-&gt;<span style="color: #006600;">get_record</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$record_id</span><span style="color: #66cc66;">&#41;</span>;
   <span style="color: #808080; font-style: italic;">//get the record from the database</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p><strong>Step 7</strong><br />
At this point, we need to go into our records.php file in the model folder.  Since Code Igniter uses a Model-View-Controller structure, database activity, server-side processing, and client-side display should be as separate from one another as possible.  You dont NEED to do this for Code Igniter to do its thing, but its good practice.</p>
<p>Inside the records.php file, well create a method called get_record to match the method referenced above.  Well use it to get a record by its primary key of ID, put the resulting data into an array, and send it back to the controller, out to the view, and ultimately into the content div we started with.</p>
<pre class="php">&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> get_record<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$record_id</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
   <span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">db</span>-&gt;<span style="color: #006600;">where</span><span style="color: #66cc66;">&#40;</span>ID,<span style="color: #0000ff;">$record_id</span><span style="color: #66cc66;">&#41;</span>;
   <span style="color: #808080; font-style: italic;">//we want the row whose ID matches the value were passing in</span>
   <span style="color: #0000ff;">$query</span> = <span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">db</span>-&gt;<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span>record_table<span style="color: #66cc66;">&#41;</span>;
   <span style="color: #808080; font-style: italic;">//get the table and put it into an object named $query</span>
   <span style="color: #0000ff;">$row</span> = <span style="color: #0000ff;">$query</span>-&gt;<span style="color: #006600;">row</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
   <span style="color: #808080; font-style: italic;">//gets the first row of the resulting dataset.  In this case, only 1 row will ever be returned</span>
   <span style="color: #0000ff;">$results</span><span style="color: #66cc66;">&#91;</span>record<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #0000ff;">$row</span>-&gt;<span style="color: #006600;">ID</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span>name<span style="color: #66cc66;">&#93;</span> = <span style="color: #0000ff;">$row</span>-&gt;<span style="color: #006600;">name</span>;
   <span style="color: #808080; font-style: italic;">//here, we create a multi-dimensional array holding the returned values</span>
   <span style="color: #808080; font-style: italic;">//based on the key.</span>
   <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">$results</span>;
   <span style="color: #808080; font-style: italic;">//send the record back to the controller</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p>The trickiest part of this section is the array.  It seems pretty complex from here, but youll see soon enough how it breaks down into something more manageable as we go along.</p>
<p><strong>Step 8</strong><br />
Were back to the controller again, and we have one more line to add - this time to pass the resulting data into a view to be formatted and printed to the content div.  The whole method() function now looks like this:</p>
<pre class="php">&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> method<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
   <span style="color: #0000ff;">$ID</span> = <span style="color: #0000ff;">$_POST</span><span style="color: #66cc66;">&#91;</span>record_id<span style="color: #66cc66;">&#93;</span>;  <span style="color: #808080; font-style: italic;">//set the record ID</span>
   <span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">load</span>-&gt;<span style="color: #006600;">library</span><span style="color: #66cc66;">&#40;</span>database<span style="color: #66cc66;">&#41;</span>;
   <span style="color: #808080; font-style: italic;">//load the database library to connect to your database</span>
   <span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">load</span>-&gt;<span style="color: #006600;">model</span><span style="color: #66cc66;">&#40;</span>records<span style="color: #66cc66;">&#41;</span>;
   <span style="color: #808080; font-style: italic;">//inside your system/application/models folder, create a model based on</span>
   <span style="color: #808080; font-style: italic;">//the procedure outlined in the CI documentation</span>
   <span style="color: #0000ff;">$results</span> = <span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">records</span>-&gt;<span style="color: #006600;">get_record</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$record_id</span><span style="color: #66cc66;">&#41;</span>;
   <span style="color: #808080; font-style: italic;">//get the record from the database</span>
   <span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">load</span>-&gt;<span style="color: #006600;">view</span><span style="color: #66cc66;">&#40;</span>AJAX_record,<span style="color: #0000ff;">$results</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p><strong>Step 9</strong><br />
The AJAX_record.php file should be in your system/application/views folder.  Keep in mind, that when you pass an array to a view (in this case the $results array), it will be exploded inside the view.  So, the path to your record is now $record, instead of $results[record].  Also inside will be your standard HTML markup, and something like this:</p>
<pre class="php">&nbsp;
&lt; ?php <span style="color: #b1b100;">foreach</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$record</span> <span style="color: #b1b100;">as</span> <span style="color: #0000ff;">$id</span>=&gt;<span style="color: #0000ff;">$value</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
     The name associated with this record is: &lt; ?php <a href="http://www.php.net/print"><span style="color: #000066;">print</span></a> <span style="color: #0000ff;">$value</span><span style="color: #66cc66;">&#91;</span>name<span style="color: #66cc66;">&#93;</span>;?&gt;
&lt; ?php <span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;</pre>
<p>This output is what php is sending to the request object, and is also what gets loaded into the content div.  Code Igniter and JQuery make it that easy to dynamically load data using AJAX.</p>
]]></content:encoded>
			<wfw:commentRss>http://js-kit.com/rss/www.mrforbes.com/p=138</wfw:commentRss>
		<slash:comments>46</slash:comments>
		</item>
		<item>
		<title>Optimizing This Site, Part II: Use a CDN</title>
		<link>http://www.mrforbes.com/thoughts/2009/01/22/optimizing-this-site-part-ii-use-a-cdn/</link>
		<comments>http://www.mrforbes.com/thoughts/2009/01/22/optimizing-this-site-part-ii-use-a-cdn/#comments</comments>
		<pubDate>Fri, 23 Jan 2009 03:48:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[website optimization]]></category>
		<category><![CDATA[optimization]]></category>

		<guid isPermaLink="false">http://www.mrforbes.com/?p=127</guid>
		<description><![CDATA[Where I add a CDN, and my Yslow score jumps.]]></description>
			<content:encoded><![CDATA[<p>The second recommendation yahoo makes is to use a CDN - or Content Delivery Network.  The idea of a CDN is to take the uploaded files, and distribute them to servers around the world, so when a file is requested it is served from the nearest/lowest latency server.  The secondary benefit is that this also offloads some of the processing power from your server, to an entire network of servers - whose whole purpose is to serve your files as quickly as possible.  Since these are merely file servers and nothing more, generally only static content is suitable to be put onto a CDN - things like javascripts, stylesheets, and images.</p>
<p>Initially, I was planning to use Amazon's Cloudfront CDN, because it is very low cost and has Amazon backing it. However, during my research I discovered that Cloudfront is not website optimization friendly.  Specifically, it isn't a simple process to gzip files, or to set expires headers on them so they get cached.  For the sake of time, I wanted something simple.  I saw a few comments about <a href="http://www.simplecdn.com">SimpleCDN</a> - which is actually lower cost than Cloudfront, and supports those optimization methods out of the box.  One short account later, and I was ready to rock.</p>
<p>SimpleCDN offers three modes of getting your files onto their service.  I chose to use their upload tool, because while it is the most manual labor, it also offer the most fine-grained control over the files being uploaded.  All you need to do is login to their admin tool, create a 'bucket' - which is really just a folder that holds your files, and them use the provided ftp info to login to the 'bucket' and upload your files.  You can then CNAME a domain (in my case cdnc.mrforbes.com) to the service.  They give you plenty of options on how you want to serve your files - zipped or not zipped, headers set to expire after a day, 3 days, etc...  At that point, its just a matter of pointing your files to the right place in your code, and your good to go.</p>
<h4>Results</h4>
<p>If you recall, we ended <a href="/thoughts/2009/01/19/optimizing-this-site-part-i-reducing-http-requests/">Part 1 </a>with a YSlow score of 61, and an average load time of around 2 seconds.  This is pretty fast, but we'll see how a CDN helps us out.  Our grade on this YSlow metric is currently an F.</p>
<p>I followed the procedure above, and got all of my files up onto the CDN.  The one thing to keep in mind here is if you change any of the files, you generally need to rename them, relink them in the code, and re-upload them.. otherwise you'll be waiting for CDN to re-propagate, which can take up to 24 hours.  Completing this, I ran YSlow again.</p>
<p>
<a href="http://www.mrforbes.com/wp-content/gallery/yslow/optimize2.jpg" title="After reducing HTTP Requests, 61." class="shutterset_singlepic9" >
	<img class="ngg-singlepic ngg-right" src="http://www.mrforbes.com/wp-content/gallery/cache/9__295x150_optimize2.jpg" alt="optimize2.jpg" title="optimize2.jpg" />
</a>
  If you expand the image, you'll see that my site now received a Yslow score of 98.  Before you start thinking a CDN is the answer to all things optimized - keep in mind that the CDN is also gzipping and caching the files it is serving, which are other recommendations for website optimization.  Essentially, by adding SimpleCDN I changed 3 scores, not one.   My only question is, if I have all As, why did I get a 98? How do I get 100?</p>
<ol class="samples">
<li>
<table>
<tr>
<th>Initial YSlow Score:</th>
<td>D(61)</td>
<th>Final YSlow Score:</th>
<td>A(98)</td>
</tr>
<tr>
<th>Initial Page Size:</th>
<td>500k</td>
<th>Final Page Size:</th>
<td>400k</td>
</tr>
<tr>
<th>Initial Load Time:</th>
<td>2+ seconds</td>
<th>Final Load Time</th>
<td>1.5+ seconds</td>
</tr>
</table>
</li>
</ol>
<p>*Update:  I have since added a few Wordpress plugins which are loading their own images and stylesheets, so if you run YSlow on my site you won't get the same numbers I have here.  I plan to optimize again once I have decided on final functionality for the site.</p>
]]></content:encoded>
			<wfw:commentRss>http://js-kit.com/rss/www.mrforbes.com/p=127</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Optimizing This Site, Part I: Reducing HTTP requests</title>
		<link>http://www.mrforbes.com/thoughts/2009/01/19/optimizing-this-site-part-i-reducing-http-requests/</link>
		<comments>http://www.mrforbes.com/thoughts/2009/01/19/optimizing-this-site-part-i-reducing-http-requests/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 04:57:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[website optimization]]></category>
		<category><![CDATA[optimization]]></category>

		<guid isPermaLink="false">http://s52837.gridserver.com/?p=121</guid>
		<description><![CDATA[Where I combine css and javascript files, and put as many images into css sprites as possible]]></description>
			<content:encoded><![CDATA[<p>According to YSlow, I received an F for the number of http requests made by my homepage.  This page currently has 23 http requests, including 12 javascript files and 5 css files.  This is way too many, and we need to bring this number down.  <a href="http://developer.yahoo.com/performance/rules.html">Here is a link</a> to what Yahoo has to say about reducing HTTP requests.  I'll list my updates in the same order.</p>
<ol class="normal">
<li>
<h4>Combined Files</h4>
<p>It makes sense that the first thing I should do is combine those javascript and css files.  I certainly don't need 17 when 2 or 3 will do just fine.  So, what I'm going to do is take all of my separate javascript files, open them up, and copy and paste the code into one large file.  Yes, this makes editing a little more time consuming, since you need to navigate a whole huge file to get the piece you want.  Luckily, there are plugins available for different programming languages which will do this for you (pack:tag for java is an example).  That way you can edit your original code, save it, and let the server handle this step.  My site is simple, and if you aren't that technically inclined, this method works so I'm outlining it here.
</p>
<p>Next, I'm going to do the same with the stylesheets.  When I load YSlow and click on 'components', I see that one of my wordpress plugins is loading 2 stylesheets, so even with combining my own two I will still be loading three.  I don't really want this, so I did a search for the file in question, commented it out of the autoloading in the plugin (yes, it will come back if I upgrade and I'll have to do it again), and pasted it into my style.css.
</p>
<p>Now that my files are combined, I'll move on to the next recommended step.</p>
</li>
<li>
<h4>CSS Sprites, Image Maps, Inline Images</h4>
<p>Okay, I cheated a little bit because I did this when I exported the original PSD.  There are a few non-css-sprited images on the homepage, but they are there of necessity.   The background, because its very wide and needs to repeat.  The ocean in the footer for the same reason (which is also a png so the island can be seen behind it - even though a gif would be much smaller in file size),  and the latest creations graphic (which is also currently a png, but I will likely change to a JPG as part of the optimization).  The clouds and balloons are also graphics, but out of necessity - they need to be resizable.
</p>
<p>Image maps wouldn't have really helped me on this design, and to be honest - I'm not a fan of inline images.  Until there is a tool that automates their inclusion, adding that kind of code to an html page feels totally contrary to the entire value of CSS.</p>
</li>
<li>
<h4>Wait, let's do a little more.</h4>
<p>YSlow Step 10, minimize js, and Step 6 - put all javascript at the bottom are separate steps, but related to this exercise, so I'll take care of them now.  Currently, the site.js file is 173k, quite large.  However, we can compress this by removing comments and whitespace, and shortening variable names.  Again, we don't have to do this ourselves.  In fact, we can even do it online <a href="http://yui.2clics.net/">here</a>.   After minimization, that 173k file gets shrunk down to 93k. </p>
<p>As for moving the javascript to the bottom of the page,  I'll just take my script and put it into the footer. I see that there are two javascript files being autoloaded into the header by the nggallery plugin.  I want to get those to the bottom too, but will do so at a later time.
</li>
</ol>
<h3>Results</h3>
<ol class="samples">
<li>
<table>
<tr>
<th>Initial YSlow Score:</th>
<td>F(39)</td>
<th>Final YSlow Score:</th>
<td>D(61)</td>
</tr>
<tr>
<th>Initial Requests:</th>
<td>23</td>
<th>Final Requests:</th>
<td>15: 3 js, 2 css, 9 images</td>
</tr>
<tr>
<th>Initial Page Size:</th>
<td>600k</td>
<th>Final Page Size:</th>
<td>500k</td>
</tr>
<tr>
<th>Initial Load Time:</th>
<td>6+ seconds</td>
<th>Final Load Time</th>
<td>2+ seconds</td>
</tr>
</table>
</li>
</ol>
<p>
<a href="http://www.mrforbes.com/wp-content/gallery/yslow/optimize2.jpg" title="After reducing HTTP Requests, 61." class="shutterset_singlepic9" >
	<img class="ngg-singlepic ngg-right" src="http://www.mrforbes.com/wp-content/gallery/cache/9__298x150_optimize2.jpg" alt="optimize2.jpg" title="optimize2.jpg" />
</a>

<p>As you can see from these results, reducing the number of HTTP requests and minimizing our javascripts has increased load times by around 300%. We also raised our YSlow score by over 22 points.  Not bad for about 30 minutes worth of optimizing.</p>
<p>Coming up next - adding Amazon Cloudfront as a Content Delivery Network</p>
]]></content:encoded>
			<wfw:commentRss>http://js-kit.com/rss/www.mrforbes.com/p=121</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Optimizing This Site, Prelude</title>
		<link>http://www.mrforbes.com/thoughts/2009/01/18/optimizing-this-site-prelude/</link>
		<comments>http://www.mrforbes.com/thoughts/2009/01/18/optimizing-this-site-prelude/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 04:40:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[website optimization]]></category>
		<category><![CDATA[optimization]]></category>

		<guid isPermaLink="false">http://s52837.gridserver.com/?p=116</guid>
		<description><![CDATA[Introduction to tracking each optimization step to see how this site improves.]]></description>
			<content:encoded><![CDATA[<p>
As I was redesigning this site, and preparing to redirect my domain to it - I decided that I would hold off on performing the optimization that is important to every website.  Instead, I thought I would create a series of posts about the process - step by step so we can all witness how the site improves which each optimization performed.  I'm going to try to go in the order presented by <a href="http://developer.yahoo.com/performance/">Yahoo</a> and their <a href="https://addons.mozilla.org/en-US/firefox/addon/5369">YSlow firefox plugin</a>, in order to present actual numbers related to the changes.
</p>
<p>
Currently, the site is totally unoptimized.  I haven't removed redundant or unused styles from the CSS.  The javascript isn't minified, its in the header, and each plugin is a separate file.  Let's see what YSlow starts us with:</p>
<p>
<a href="http://www.mrforbes.com/wp-content/gallery/yslow/yslow.gif" title="Before optimization. 39??? Yikes." class="shutterset_singlepic8" >
	<img class="ngg-singlepic ngg-right" src="http://www.mrforbes.com/wp-content/gallery/cache/8__274x150_yslow.gif" alt="yslow.gif" title="yslow.gif" />
</a>
<br />
If you enlarge the image, you'll see that we're starting off with a grade of F... and a numeric grade of 39.  The current size of the homepage is about 600k, and the time to load is around six seconds. Looks like there's a lot of room for improvement there.  The first item of concern for YSlow is the number of http requests, currently topping 17 - with 12 javascript files and 5 css files.  For our next installment, we'll try to reduce this as close to 1 and 1 as possible.</p>
<p>See you then.</p>
]]></content:encoded>
			<wfw:commentRss>http://js-kit.com/rss/www.mrforbes.com/p=116</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The New mrforbes.com</title>
		<link>http://www.mrforbes.com/thoughts/2009/01/18/the-new-mrforbescom/</link>
		<comments>http://www.mrforbes.com/thoughts/2009/01/18/the-new-mrforbescom/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 04:24:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[conversation]]></category>
		<category><![CDATA[redesign]]></category>

		<guid isPermaLink="false">http://s52837.gridserver.com/?p=114</guid>
		<description><![CDATA[Redesigned and reloaded, with all new content.]]></description>
			<content:encoded><![CDATA[<p>So, you may not even know what the OLD mrforbes.com was.  It was the last iteration of my online persona presentation website and blog, which actually had one post on it about using code ignitor and and jquery to make ajax things happen which garnered a little bit of traffic.  Alas, something happened to the server I was hosted on, and Google branded my site a malware site.  Now with new hosting and a new approach, I am re-introducing myself so to speak. </p>
<p>All of my previous posts (there were only 4) have been washed away, and I'm starting clean.  Not to worry about that code ignitor/jquery/ajax post - numerous comments suggested it didn't work.  It may not have,  I didn't test it when I posted it, because I never actually thought anyone would read it anyhow.  I promise to be more diligent in the future. </p>
<p>So for the two, three, hundred or thousand of you who may end up reading this - thanks for stopping by.</p>
]]></content:encoded>
			<wfw:commentRss>http://js-kit.com/rss/www.mrforbes.com/p=114</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Plugin: Omnitip</title>
		<link>http://www.mrforbes.com/thoughts/2009/01/18/jquery-plugin-omnitip/</link>
		<comments>http://www.mrforbes.com/thoughts/2009/01/18/jquery-plugin-omnitip/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 04:03:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[user interface]]></category>

		<guid isPermaLink="false">http://s52837.gridserver.com/?p=103</guid>
		<description><![CDATA[A production-ready enhancement to the standard javascript tooltip]]></description>
			<content:encoded><![CDATA[<p>I ended up developing the omnitip jquery plugin because I needed something a little more robust than any of the other jquery based tooltips that I was able to find.  There may or may not have been one that would have met my needs and I just didn't see it, but regardless I believe I benefited from the experience of building a jquery plugin, and hopefully you will benefit as well.
</p>
<h4>About Omnitip</h4>
<p>Omnitip  is a tooltip plugin (you can see it at work on the homepage).  What I THINK I have added to other tooltips in terms of functionality is:</p>
<ol class="normal">
<li>The ability to maintain the tooltip while hovering over it - thereby allowing things like links and forms to be loaded inside the tip</li>
<li>Ability to send included forms through ajax components and load a response using callbacks</li>
<li>Enhanced animation of tooltips, allowing not only fading but also 'travel'</li>
<li>Full browser support of tooltip transparency (including IE6)</li>
<li>Algorithmic based tooltip and tooltip 'arrow' positioning</li>
</ol>
<p>If you have a tooltip plugin that also has some, or all of these features please let me know, and I will post it here as an alternative.</p>
<p>Omnitip is also designed to be skinnable, and I have included psds and pngs that should help you accomplish this.  If you create a skin for Omnitip, PLEASE post it here.  If you have any enhancements,  suggestions for Omnitip, or questions, fire away.  If you just want to hate on my programming skills (I have no formal CS education).. if that's what helps you sleep better.</p>
<div class="col100 basemargin">
<div class="textlink left"><a href="/omnitip/demo.html">view the demo</a> or </div>
<p><a class="a_box left" href="/omnitip/jquery_omnitip_1.0.zip">Download Now &raquo;</a>
</div>
]]></content:encoded>
			<wfw:commentRss>http://js-kit.com/rss/www.mrforbes.com/p=103</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
