Categories
main

jQuery vs Prototype – Document Load: jQuery wins

Recently I started using jQuery instead of Prototype for my web applications. When I first started using a javascript library I picked Prototype because to be honest jQuery intimidated me, there was a lot of mystery about it. Well I took another look at it a few days ago and I was floored, boy I was missing out. jQuery byte for byte in my opinion kicks prototypes butt.

Take for example attaching a function to the document load and adding an onclick action to a link.

Pototype:

// Initially set everything up
init = function (){
// If there is an expand dom element
if ($('expand')){
Event.observe($('expand'), 'click', ExpandMenu, false);
}
} // Attach the onload function
Event.observe(window, 'load', init, false);

jQuery:

// Initially set everything up
$(document).ready(function(){
// On click event
$("#expand").click(function(){
// Function actions here
});
});

It may not seem like a great deal of code reduction but scanning the code from top down (say if you were a developer brought in to fix a bug) shows how more fluid jQuery is in terms of execution flow. Prototype jumps all over the place…

  1. First define the initializer function
  2. Next find the element on the page
  3. Set an observer on it and direct it yet another function
  4. Last but not least attach the initializer to the document load

It seems that is the exact opposite order of its execution, jQuery on the other hand…

  1. Create a function and attach it to the document ready state
  2. Create a function and attach it to a dom element on click
  3. Done.

First round goes to: jQuery

Categories
main

Refresh OS X Finder

Refresh Finder ButtonThe Apple products and community never cease to amaze me. When there is a problem to solve more than likely someone has already created an elegant solution. An experience I had today reinforced my findings ten fold.

I have a few shares on a network drive that I connect from OS X via Samba. Files get populated into those folders by other applications and when they are ready I goto the directory and pick them up. Well Finder has a mysterious refresh rate for directories… I have never been able to figure it out and there is to my knowledge no hotkey to manually refresh.

So I goto good ol’ Google to find a solution… Looks like nothing built in, but there is this nifty utility called Refresh Finder. Built on AppleScript it is lightweight and does what it needs and gets out of the way.

I hate to say it but it far surpasses any elegant solutions I have seen for Windows. Usually those include some constantly running application in the background, starting at startup, always looking for an update, and probably costing $19.99 nagware.

Downloaded and installed in 2 minutes. This will save a lot of time, usually I end up having to just randomly click on folders to hit something that is not cached so Finder can do a refresh. Now there is a refresh button similar to on Safari in the Finder toolbar and life is quite a bit less stressful.

A definite download for any Mac user. If I were to rate it a 10 out of 10 would be in order. Great work S�derhavet.

Download Refresh Finder