YUI good for your performance
One of the cons of using any of the good and popular third-party JS libraries is the file size of the .js files associated with them. A lot has been done by the library developers to address this issue - providing minified versions, segregating the script files based on what they do and using loading-on-demand, among others. There's more good news - Yahoo is now offering hosting of their YUI library files.
How is it good for you?
- less on the bandwidth bill - you don't need to worry about hosting these files yourself
- high availability - well Yahoo is behind this, so you can rest assured that these files are delivered to your surfer
- small downloads - Yahoo hosts the minified versions and gzips them
- files already cached!
The last one is the topic I had in mind with the this blog's title. Since Yahoo will be using the same locations for the libraries you need and since Yahoo is the most popular site, chances are your visitors have already checked their Y! mail or their Y! finance page and searched or done anything on the Yahoo network of sites. This means they have already requested and (hopefully) cached these .js files. And as proved before, lowering the number of HTTP requests is top 1 performance optimization you can ever do.
Even better is that you can include only libraries you need (less transfer) or you can include several in a batch (less requests).
If you only need Event and DOM, include only yahoo-dom-event.js (8K)
If you need only Event, DOM, AJAX, include yahoo-dom-event.js and connection-min.js (8K + 4K)
If you also need more like Drag and Drop and animation and AJAX, why not include all utility classes at once, utilities.js. After all this file is 22K, probably less than two images that will appear on your page.
Note: all filesizes above are when files are gzipped, which is how Yahoo serves them.
So bottom line, your visitors hit your site and, lo and behold, they have all the JS already cached, resulting in your page loading as fast as a rocket
Sweet.
April 2nd, 2007 at 2:01 pm
Smart move from Yahoo. I've dreamt for long about something similar with Prototype (integration right into firefox ? drools …)
April 6th, 2007 at 6:58 am
[…] YUI good for your performance visitors hit your site and, lo and behold, they have all the JS already cached, resulting in your page loading as fast as a rocket (tags: YUI Cache JavaScript Hosting) […]
April 11th, 2007 at 1:21 am
[…] phpied.com: YUI good for your performance Caching is a good point, which was brought up at last years @media. […]
April 17th, 2007 at 7:04 pm
Though, there's a trade off between including only the libraries you want and avoiding fetches, since the likelihood of a cache hit goes down as the number of libraries to cache goes up. The more developers who use the "everything" option the more likely it is that somebody else incurred the hit from fetching that big file.
August 26th, 2007 at 8:23 am
Hi
I'm starting to host (non YUI) JS libraries on a central location: It will solve both the bandwith problem and caching problem.
Expect a launch in less than a week - sign up to be notified at http://www.hosted-js.com