JavaScript Source Joiner/Combiner
The complexity of JavaScript code has increased rapidly over the last two years. The emerging of various JavaScript libraries/frameworks along with Ajax technology enable us to build sophisticate applications which are comparable to desktop ones. A mid-size to large-size Ajax/JavaScript applications normally consist of thousands lines of code. For readability and navigability, it is practical and logical to separate the code into different files. For example, allocate one file for each class. Many developers don't want to or at least hesitated at doing so because more JavaScript files means additional HTTP requests to the server, which impacts page loading efficiency.
A Useful JavaScript Image Loader
I released a YUI implementation of image gallery script a month ago. While it was quite an enjoyable experience to explore the potential of YUI and JavaScript, I found I have created many userful code snips (for instance this Loading Panel) along the way.
Today I am going to show you another useful JavaScript code snip: Image Loader. What! You might ask. I admit that name is too generic, but it does what it does - it helps you to load images using JavaScript. Just give it an image URL, it will return a DOM image object that can be used for dynamic loading of images. This script provides a loading completion event, which is very useful for displaying preloader or extra information when the image is being loaded.
The original image loader I created relies on YUI, but I want to make it as portable as possible, so I created a standalone version.
How to Create a WordPress Theme Viewer
For WordPress veteran this might not be new, which is, let visitor preview multiple themes in one WordPress installation. It puzzled me quite a while before I figured out how to do it. The very reason for the need of this feature is that I want to allow regular users to view different themes on a WordPress powered website. I wasn't able to until I ran into this page. Yea right! A theme switcher. I installed this plugin and tested. It provides the exact function that I need. Fantastic.
Now here comes the interesting stuff. The official documentation documented the plugin is as follow, which outputs a list of links that can switch to a specific theme:
A YUI Loading Panel Widget
Probably needless to say, but here it is. A web page which is processing a lengthy Ajax request and doesn't provide a loading indicator of any kind will mostly mislead the user to think that the page has stopped responding. So the solution? Use a loading indicator of course. Here's a very handy loading indicator widget for Ajax programmers who use YUI.
Files
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.4.1/build/assets/skins/sam/skin.css"> <script type="text/javascript" src="http://yui.yahooapis.com/2.4.1/build/utilities/utilities.js"></script> <script type="text/javascript" src="http://yui.yahooapis.com/2.4.1/build/container/container-min.js"></script> <script type="text/javascript" src="[PATH_TO_JS]/loadingpanel.js"></script> </link>
How to Use
First, create a new instance of loading panel. After that, you can call show or hide method on the loading panel object.
var loadingPanel = new yuiLoadingPanel();
//loadingPanel.show();
//loadingPanel.show("Processing...");
//loadingPanel.hide();
The user can close the loading box by clicking on the cancel link. If you want to handle this situation, you can subscribe to the cancelEvent:
loadingPanel.cancelEvent.subscribe(function(e, a, o){
alert('You clicked cancel!');
});
Apache Performance Problem on Vista
Just switch my operating system to Vista, and my biggest complaint about it is that it breaks my Apache HTTP server. The server still runs, but very slowly. The symptom is as follow: every time I reload a web page from the browser, there usually is a 2-3 seconds delay before the loading sequence starts. This shouldn't be happening because I serve all my files locally, so I expect no delay at all. Also, this behavior does not occur in XP.
After some excessive searches, I found a forum post (forgot the URL, will update this when I hit the site again) that suggests uninstalling Zone Alarm will resolve the problem. I gave it a try since I was in nowhere in solving the problem. Surprisingly the uninstallation did cure the delay issue of Apache. Beware that you HAVE TO restart Vista after uninstallation, otherwise you will not see the changes.
That's right, I uninstalled my firewall. So replacement? I like Zone Alarm and enjoy using it, but it doesn't seem to be very stable on Vista. However, I've found another great firewall product, Comodo Firewall Pro, which is a commercial grade firewall free of charge.

