Wednesday, October 18th, 2006

YUI: Setting the record on library file size

Category: JavaScript, Library, Yahoo!

Eric Miraglia has written a detailed post on YUI: Weighing in on Pageweights, that discusses the “file size” issue of JavaScript libraries:

When we opened up the YUI Library in February, we talked about some of our motivations for creating an entirely new JavaScript toolkit. One of those motivations, we said, was that Yahoo!’s diverse engineering communities demanded a solution that was lightweight, one that could be applied à la carte without unnecessary k-weight overhead.

With YUI now encompassing three CSS foundation libraries, six utilities and nearly a dozen UI controls, we thought it would be a good time for a progress report on library size, page weights, and YUI’s à la carte architecture. (Note: This article focuses almost exclusively on pageweight, which itself is only one element of overall performance. Filesizes described here are based on YUI’s 0.11.4 release.)

Eric measures the file size before and after compression and minification.

The graph tells the story on how the file size changes dramatically when munged with. As with some of the other frameworks, they also have an a la carte strategy so you can pick and choose the pieces of the library you need.

Do not download the kitchen sink, use one piece, and complain about the file size :)

Posted by Dion Almaer at 7:19 am

4 rating from 21 votes


Comments feed TrackBack URI

Article Title should probably be “Stetting the record STRAIGHT on library file size”. The YUI library doesn’t belong in the Guiness Book or anything.

Comment by anonymous — October 18, 2006

moo is the best library. hands down. end of discussion.

Comment by Karl Moz — October 18, 2006

Koolaid! I like the YUI… its has feature no other framework has… and I am a Prototype supporter. I have nothing against jQuery although the “It’s a way of life” mentality that some of its supports express is annoying and misleading and just weird… its a js framework not a cure for cancer. Moo tools is cool too (I havent used it but I keep hearing good things). I have dabbled in compression and gotten Scriptaculous very very low (35kb for the kitchen sink) and Prototype (all versions between 14-19kb).

Comment by Mario — October 18, 2006

I think all libraries have their advantages but the yui library its the one that has the better documentation. And that for me its a big difference.

Comment by rodrigo — October 18, 2006

Here, here! Yes, YUI differentiates itself by it’s excellent documentation. Many others have almost nothing.

Comment by ajaxianfading — October 18, 2006

Yahoo has tons of money to throw at it too while others volunteer.

Comment by Mario — October 18, 2006

Admirable job by the YUI guys, however, for large scale frameworks that provide a full GUI stack including rich grids, forms, databinding facilities, etc, the best way to minimize library size is not line by line code minimization but rather factoring for reuse.

For example, SmartClient’s core Layout class is used in Windows, Toolbars, TabBars, Grids, Forms – well basically everywhere. Without that kind of code sharing approach, the more sophisticated your components get the more bloat you will have.

Of course we also apply code minimization techniques, which go a bit beyond YUI, eg, renaming all internal properties.

Comment by Charles Kendrick — October 18, 2006

I don’t think this sets the record straight at all. To get very basic functionality you will need a library of about 30K (events, connect, DOM). This is a 30K library that doesn’t do anything! If you add in FX and drag/drop etc then you are back to a 60-70K library. jQuery and mootools achieve all of this in a fraction of the file size (more like 20K for the lot). A nice PR move, but people like small tools not Olde Worlde Javaesque libraries.

Comment by Dean Edwards — October 18, 2006

Dean, I am not sure where you are getting your information.

The complete yui library with drag/drop/fx etc. if you take the “whole kitchen sink” is 30K. Not the 60-70K you quote.

Guys, realize that Eric wrote this article not to make a statement that the YUI library is better than all other libraries because its file size is small. (I am sure there are some smaller ones… but then it’s hard to compare because features are different.) That would be a ridiculous argument and one we do not make. In fact no comparisons are drawn at all.

The background to this article is that there were a number of articles, blog posts, conference talks, etc. that claimed that the YUI library was bloated, weighing in at over 200K. The point of the article was to clearly document the current state of this version of the library and let folks know the real page weight issue.

The page weight is important… but of course it is only one factor in evaluating a library.

Disclaimer: I work at Yahoo! However, I do like the YUI library. I also originally co-founded Rico. I liked Rico. I like Scriptaculous. I love Rails. I think Dojo is an awesome library. I think Moo & mochikit rock. Frankly, I am glad that a number of good toolkits are emerging. It keeps us all honest and trying harder to create better solutions for our users.

Comment by Bill Scott — October 18, 2006

@Bill – I added up the totals from the YUI graphic. Try it yourself.

Comment by Dean Edwards — October 20, 2006

It looks more like 60-70K to me as well. I think apples to apples here is uncompressed. Moo tools is 20K before gzipping right? Also, it seems like it would be important to also consider file units, not just size. If you have a large number of script files, it will take the browser a while to make all the requests and deal with latency (and connection limits) even if they are small. It seems a bit naive to only consider total size, when latency is an important issue. I think it might be useful to have a single file version of the entire YUI library. I bet that would be faster to download 6 or 7 files. I could be wrong, but it would also be interested to do a little benchmarking on that. It is not that are hard to concatenate all the js files, maybe I will try it out…

Comment by Kris Zyp — October 20, 2006

Leave a comment

You must be logged in to post a comment.