Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading multiple CSS files with single http request

Tags:

http

css

yahoo

When I view the source code of yahoo mail, I see multiple css files in a link tag using an & symbol as shown below:

href="http://mail.yimg.com/zz/combo?kx/ucs/uh/css/271/yunivhead-min.css&kx/ucs/uh/css/221/logo-min.css&kx/ucs/avatar/css/17/avatar-min.css"

Does anyone know, how they separate each file and load them all using a single http request?

like image 940
M Ram Kumar Avatar asked Nov 04 '22 02:11

M Ram Kumar


1 Answers

In this case, there seems to be a script that joins the css files into a single response.

The path to the script is http://mail.yimg.com/zz/combo. It accepts several parameters containing paths to CSS files, which will then be joined and possibly minified.

If you play around with the URL, you can see that you could remove the -min-Prefixes from the URL and you get the unminified CSS file in return: http://mail.yimg.com/zz/combo?kx/ucs/uh/css/271/yunivhead.css&kx/ucs/uh/css/221/logo.css&kx/ucs/avatar/css/17/avatar.css

There are several CSS minifiers around, for example CSSmin. But as this is a Yahoo page, they probably use their own CSS compressor, YUI. For details about how it works, see http://developer.yahoo.com/yui/compressor/#work.

like image 50
Danilo Bargen Avatar answered Nov 07 '22 21:11

Danilo Bargen