Quality Reads

Saturday, November 11, 2006

Optimizing Page Loading in ColdFusion

I was reading this posting by Aaron Hopkins (a Google Engineer) about optimizing page loading when I started to think about my experimentation with different AJAX implementations. Every time I tried a new implementation, I'd end up with a hodge podge of javascript files on my demo website (some from the previous framework, some from the new). After reading that post, I've come to realize that even though it may be nicer to link to each javascript file individually, this behavior can negatively affect load time. This is due in large part to modern browsers limitations to only allow two outstanding HTTP Requests at any time.
Personally, I still like keeping things organized but I don't want to sacrifice performance for it. So, I've started using the following approach for all my sites:
  • Create two ColdFusion pages (or PHP, Ruby, etc) that change the mime type to "text/js" and "text/css" respectively.

  • Then include all the appropriate js or css files using <cfinclude>.

/* js_compilation.cfm*/
<cfcontent type="text/js">
<cfinclude template="js/core.js">
<cfinclude template="js/prototype.js">
<cfinclude templat="js/rico.js">
  • Lastly, you should simply reference that file in the Head section of the calling page.

<script src="js_compilation.cfm" type="text/js">
Do the same thing for all your assorted CSS files and you're load time should be significantly improved without sacrificing organization. You can keep your file structure simple and efficient.
Cheers,
Todd

PS-I know everyone should be crunching their JS files into one library but we can't all afford to do that. This is a simple step that everyone can handle.

Tuesday, November 07, 2006

Stikkit! and my Vista Experience

I should probably start off where I left off. Vista. Once I got past all the flashy new UI components,I was left with a very sour taste in my mouth. Backward compatibility is a serious issue. I realize I'm using a pre-release version but more than half of the programs I became accustomed to using on XP crash on Vista. The most annoying of all is Eclipse which throws a JVM error (Java error) randomly when I'm doing any file folder manipulation. Since I use it all the time for programming, its particularly disruptive. Another killer is the pre-release for Fireworks 9 (Adobe's image editing suite geared towards web design), I haven't been able to get the thing to install yet. Tried everything under the sun, crashes right when I starts the main installation. You know when the little status bar comes up. I've come to hate that damn bar. I guess I shouldn't surprised. Microsoft's products, excluding SQL Server, tend to be skin deep apps. Real pretty when you first pull them up and you read about all the stuff they do but then you realize all the hoops you have to jump through to get there. I think thats the reason I've become so partial to programming all my work rather than using Excel et al. I can define the interface to support exactly what I'm doing. Nonetheless, lets move on to the new web 2.0 app. Stikkit. Its got a very sleek UI with some sweet features not overtly apparent. The sites general concept is a web-based stick-it note, hence stikkit. Type in something you want to remind yourself of with a date or perhaps a buddy you want to share the note with and the application figures it out on its own. I tested it out by typing "I have a presentation due on Monday". In response, it created a calendar event automatically. I wonder if they're using an AI friendly server-side language like python to get the job done. I'll poke around and see what I find out. Cheers,
Todd