You can now reduce the number of HTTP requests to serve all the YUI javascript dependendices to a single HTTP request. As an example, we just updated our Web Speed Check to use a single HTTP request to load all the YUI javascript dependencies using the new YUI combo loader…
<script type="text/javascript" src="http://yui.yahooapis.com/combo?2.5.2/build/yahoo-dom-event/yahoo-dom-event.js&2.5.2/build/animation/animation-min.js&2.5.2/build/connection/connection-min.js&2.5.2/build/element/element-beta-min.js&2.5.2/build/datasource/datasource-beta-min.js&2.5.2/build/datatable/datatable-beta-min.js"></script>
This replaced the following code…
<script src="http://yui.yahooapis.com/2.5.2/build/yahoo-dom-event/yahoo-dom-event.js"></script>
<script src="http://yui.yahooapis.com/2.5.2/build/animation/animation-min.js"></script>
<script src="http://yui.yahooapis.com/2.5.2/build/connection/connection-min.js"></script>
<script src="http://yui.yahooapis.com/2.5.2/build/element/element-beta-min.js"></script>
<script src="http://yui.yahooapis.com/2.5.2/build/datasource/datasource-beta-min.js"></script>
<script src="http://yui.yahooapis.com/2.5.2/build/datatable/datatable-beta-min.js"></script>
So, we’ve reduced from making six HTTP requests to making a single HTTP request to load the YUI javascript dependencies and this reduces the total page load time. Thanks to Eric Miraglia for this tip.
Bookmark at:StumbleUpon | Digg | Del.icio.us | Dzone | Newsvine | Spurl | Simpy | Furl | Reddit | Yahoo! MyWeb
Entries (RSS)
So how does this combo loader actually work?
The new combo loader recently provided by Yahoo concatenates the provided YUI scripts together allowing the YUI scripts to be retrieved in a single script tag (and thus a single HTTP request). The syntax of the combo loader should be self evident from the example above. Note this is a YUI only solution — in other words, you cannot use the YUI loader to concatenate your own scripts together.
[...] roll up all of your JS files from YUI into a single files. I found a pointer to this little tidbit here. This really helps to reduce the number of javascript includes that are required on [...]
I don’t get it. I mean it’s a good idea, don’t get me wrong, but shouldn’t HTTP keep-alive solve this problem? As I understand it if the requests were properly pipelined there would only need to be a handful of extra headers with each file (assuming the files are large, on the order of 5k or so, this is probably only 1-2%). Or is someone (client, server) not using keep-alive properly? [Edit: I guess maybe there's extra file-retrieval time on the server side, but I'm pretty sure Yahoo caches these things].
I didn’t benchmark it myself. I’ve been trying to implement the YUI performance recommendations — they have it #1 on their list…
http://developer.yahoo.com/performance/