Thread: [Cppcms-users] combining all js and css requests in a single file
Brought to you by:
artyom-beilis
From: Aris S. <ari...@gm...> - 2010-12-16 07:19:11
|
Hi, My opinion in web development, specifically if we have many "js and css" resources, although we have high performance http server, many "js and css" requests will result poor performance (vary in case). A technique used in YUI javascript framework is with combining all request in single file. They provide, named Combo API to access YUI resources, complete with its dependency configurator. Here the example of combining 4 javascript request: <script type="text/javascript" src="http://yui.yahooapis.com/combo?2.8.2r1/build/yahoo/yahoo-min.js&2.8.2r1/build/dom/dom-min.js&2.8.2r1/build/event/event-min.js&2.8.2r1/build/element/element-min.js&2.8.2r1/build/tabview/tabview-min.js"></script> and for css: <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/combo?2.8.2r1/build/fonts/fonts-min.css&2.8.2r1/build/tabview/assets/skins/sam/tabview.css"> Combo API is useful to minimize http request. How about added this feature (combo api) in CppCMS so we don't need combine it ourself? How about combining small images so we can access it with css sprite? -aris |
From: Artyom <art...@ya...> - 2010-12-16 08:33:42
|
> Hi, > > My opinion in web development, specifically if we have many "js and > css" resources, although we have high performance http server, many > "js and css" requests will result poor performance (vary in case). > > A technique used in YUI javascript framework is with combining all > request in single file. They provide, named Combo API to access YUI > resources, complete with its dependency configurator. > Here the example of combining 4 javascript request: > > <script type="text/javascript" >src="http://yui.yahooapis.com/combo?2.8.2r1/build/yahoo/yahoo-min.js&2.8.2r1/build/dom/dom-min.js&2.8.2r1/build/event/event-min.js&2.8.2r1/build/element/element-min.js&2.8.2r1/build/tabview/tabview-min.js"></script> >> > > and for css: > > <link rel="stylesheet" type="text/css" >href="http://yui.yahooapis.com/combo?2.8.2r1/build/fonts/fonts-min.css&2.8.2r1/build/tabview/assets/skins/sam/tabview.css"> >> > > Combo API is useful to minimize http request. > > How about added this feature (combo api) in CppCMS so we don't need > combine it ourself? First of all, as far as I understand you can just use some css/javascript compressor and use it instead of ordinary file. And probably specialized compressors would do a good job. > How about combining small images so we can access it with css sprite? Isn't it what HTTP-Keep-Alive and for? Also HTTP/1.1 allows you to send several requests for different images without waiting for completion of downloading first one. Isn't it better? Generally most web servers know to serve static files a way better than any framework I know for a simple reason - this is what they are benchmarked against most often. They use best OS API like sendfile or others to do the job done. I'm not sure how much would it give you to push such thing in framework, also how exactly can you combine serveral images in single request? Artyom |
From: Aris S. <ari...@gm...> - 2010-12-16 10:22:09
|
> First of all, as far as I understand you can just use some css/javascript > compressor > and use it instead of ordinary file. And probably specialized compressors would > do a good job. thanks >> How about combining small images so we can access it with css sprite? > Isn't it what HTTP-Keep-Alive and for? > > Also HTTP/1.1 allows you to send several requests for different images without > waiting for completion of downloading first one. Isn't it better? I read from some browsing, they are optimally used in 4 parallel request because of DNS look up time. If the images small enough to combine, it will give me more alternative. I think I need some test. By the way, how many a [maximum] size of an http response? How to check it? I use firefox firebug plugin, and no information about it. > Generally most web servers know to serve > static files a way better than any framework I know for a simple reason - this > is what they are benchmarked against most often. They use best OS API like > sendfile or others to do the job done. I'm not sure how much would it > give you to push such thing in framework, also how exactly can you combine > serveral > images in single request? I think about small, less static, same size, related images, such as image profile in social web and try another alternative to pull them with combining and maybe caching. I can use libgd. |
From: Artyom <art...@ya...> - 2010-12-16 11:55:17
|
----- Original Message ---- > From: Aris Setyawan <ari...@gm...> > > First of all, as far as I understand you can just use some css/javascript > > compressor > > and use it instead of ordinary file. And probably specialized compressors >would > > do a good job. > thanks > > >> How about combining small images so we can access it with css sprite? > > Isn't it what HTTP-Keep-Alive and for? > > > > Also HTTP/1.1 allows you to send several requests for different images >without > > waiting for completion of downloading first one. Isn't it better? > I read from some browsing, they are optimally used in 4 parallel > request because of DNS look up time. I was talking about HTTP Pipelining, Read this: http://en.wikipedia.org/wiki/HTTP_pipelining > I think about small, less static, same size, related images, such as > image profile in social web and try another alternative to pull them > with combining and maybe caching. I can use libgd. There is no problem serving images with CppCMS this is rather simple you don't need anything special for it just give correct content type and write it into output. And of course you can cache them in CppCMS using internal CppCMS cache. But still you need to define what you want and how to serve the files. You can even do something like that: response().content_type("image/jpeg"); sql << "SELECT image FROM profiles WHERE user_id = ?" << uid << cppdb::row >> resonse.out(); Artyom |
From: Aris S. <ari...@gm...> - 2010-12-16 20:43:36
|
> I was talking about HTTP Pipelining, Read this: > > http://en.wikipedia.org/wiki/HTTP_pipelining HTTP pipelining is disabled in most browsers. > You can even do something like that: > > response().content_type("image/jpeg"); > sql << "SELECT image FROM profiles WHERE user_id = ?" << uid << cppdb::row >>> resonse.out(); thanks. this is simple. |