Daily Archives: December 10, 2008

Open++ Adds Anything You Want to Your Right-Click Menu [Featured Windows Download]

Windows only: Free utility Open++ adds a new submenu to your right-click context menu with advanced options for adding virtually any function you could want.

Rather than add a bunch of its own custom commands (though it does have a few handy defaults, like Copy Path), Open++ provides a versatile utility for adding your own functions. You can launch files, folders, or applications complete with special arguments, a user-defined working directory, custom icons, and even custom file associations (so the command only shows up when you right-click a certain file type). For a similar app, check out previously mentioned FileMenu Tools. Open++ is a free download, Windows only.

GotReception Maps Cellphone Coverage [Cell Phones]


GotReception is a user driven map of cellphone reception strength. Users can login and submit reviews of the location they are at and the cellphone reception they are recieving there. GotReception then compiles the results of the thousands of user submissiosn into a cloud style map showing the clusters of good reception for the carrier you search for. The sample map in the screenshot above shows coverage for the five major carriers in Detroit. You can look at all of them to get an idea of where they overlap and which have the greatest reach, or par it down to just the carrier you are interested in. For another cellphone coverage tracking service, check out Signal Map.

Class Variables

I previously wrote about the lack of support for private methods when working with Objective-C. As part of that post I presented a few work-arounds. Along the same lines, there are is no support for class variables in Objective-C. This post will explore this a little further and walk through a short example that shows [...]

3 reasons why you should let Google host jQuery

All too often, I find code similar to this when inspecting the source for public websites that use jQuery:

<script type="text/javascript" src="/js/jQuery.min.js"></script>

If you’re doing this on a public facing* website, you are doing it wrong.

Instead, I urge you to use the Google AJAX Libraries content delivery network to serve jQuery to your users directly from Google’s network of datacenters. Doing so has several advantages over hosting jQuery on your server(s): decreased latency, increased parallelism, and better caching.

In this post, I will expand upon those three benefits of Google’s CDN and show you a couple examples of how you can make use of the service.

* None of this is relevant to internal applications served over a LAN. It would be as likely harm performance as improve it.

Decreased Latency

A CDN — short for Content Delivery Network — distributes your static content across servers in various, diverse physical locations. When a user’s browser resolves the URL for these files, their download will automatically target the closest available server in the network.

In the case of Google’s AJAX Libraries CDN, what this means is that any users not physically near your server will be able to download jQuery faster than if you force them to download it from your arbitrarily located server.

There are a handful of CDN services comparable to Google’s, but it’s hard to beat the price of free! This benefit alone could decide the issue, but there’s even more.

Increased parallelism

To avoid needlessly overloading servers, browsers limit the number of connections that can be made simultaneously. Depending on which browser, this limit may be as low as two connections per hostname.

Using the Google AJAX Libraries CDN eliminates one request to your site, allowing more of your local content to downloaded in parallel. It doesn’t make a gigantic difference for users with a six concurrent connection browser, but for those still running a browser that only allows two, the difference is noticeable.

Better caching

Potentially the greatest (yet least mentioned) benefit of using the Google AJAX Libraries CDN is that your users may not need to download jQuery at all.

No matter how aggressive your caching, if you’re hosting jQuery locally then your users must download it at least once. A user may very well have dozens of identical copies of jQuery-1.2.6.min.js in their browser’s cache, but those duplicate files will be ignored when they visit your site for the first time.

On the other hand, when a browser sees multiple subsequent requests for the same Google hosted version of jQuery, it understands that these requests are for the same file. Not only will Google’s servers return a 304 “Not Modified” response if the file is requested again, but also instructs the browser to cache the file for up to one year.

This means that even if someone visits hundreds of sites using the same Google hosted version of jQuery, they will only have to download it once.

Implementation

By now, you’re probably convinced that the Google AJAX Libraries CDN is the way to go for your public facing sites that use jQuery. So, let me show you how you can put it to use.

Of the two methods available, this option is the one that Google recommends:

The google.load() approach offers the most functionality and performance.

For example:

<script type="text/javascript"         src="http://www.google.com/jsapi"></script> <script type="text/javascript">   // You may specify partial version numbers, such as "1" or "1.2",   //  with the same result. Doing so will automatically load the    //  latest version matching that partial revision pattern    //  (i.e. both 1 and 1.2 would load 1.2.6 today).   google.load("jquery", "1.2.6");     google.setOnLoadCallback(function() {     // Place init code here instead of $(document).ready()   }); </script>

While there’s nothing wrong with this, and it is definitely an improvement over hosting jQuery locally, I don’t agree that it offers the best performance.

Firebug image of the longer loading time caused by jsapi

As you can see, loading, parsing, and executing jsapi delays the actual jQuery request. Not usually by a very large amount, but it’s an unnecessary delay. Tenths of a second may not seem significant, but they add up very quickly.

Worse, you cannot reliably use a $(document).ready() handler in conjunction with this load method. The setOnLoadCallback() handler is a requirement.

Back to basics

In the face of those drawbacks to the google.load() method, I’d suggest using a good ‘ol fashioned <script> declaration. Google does support this method as well.

For example:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script> <script type="text/javascript">   $(document).ready(function() {     // This is more like it!   }); </script>

Not only does this method avoid the jsapi delay, but it also eliminates three unnecessary HTTP requests. I prefer and recommend this method.

Conclusion

According to a recent study, Google will consume 16.5% of all consumer Internet capacity in the United States during 2008. I think it’s fair to say that those guys know how to efficiently serve up some content.

The opportunity to let the pros handle part of your site’s JavaScript footprint free of charge is too good to pass up. As often as even returning users experience the “empty cache” load time of your site, it’s important to take advantage of an easy optimization like this one.

What do you think? Are you using the Google AJAX Libraries CDN on your sites? Can you think of a scenario where the google.load() method would perform better than simple <script> declaration?

I wonder why hasn’t this been done for MicrosoftAjax.js?

 

###

Originally posted at Encosia. If you’re reading this elsewhere, come on over and see the original.

 

3 reasons why you should let Google host jQuery for you

WP Like Button Plugin by Free WordPress Templates