davioliveiraweb / spriteme

Automatically exported from code.google.com/p/spriteme
0 stars 0 forks source link

CoolRunnings: size comparison #15

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In addition to showing the reduction in HTTP requests, it'd be nice to show
byte savings. We could do this in CoolRunnings. It has to download all the
individual images, and also knows the size of the resultant sprite. Adding
this to the json response would work.

Original issue reported on code.google.com by stevesou...@gmail.com on 1 Sep 2009 at 6:05

GoogleCodeExporter commented 9 years ago

Original comment by stevesou...@gmail.com on 1 Sep 2009 at 6:06

GoogleCodeExporter commented 9 years ago

Original comment by stevesou...@gmail.com on 1 Sep 2009 at 11:02

GoogleCodeExporter commented 9 years ago
I added size.cgi which returns the Content-Length of images in a script. It's 
slow -
you have to run it on all the images. I'll add a new issue to handle batch mode.

Original comment by stevesou...@gmail.com on 4 Sep 2009 at 4:40

GoogleCodeExporter commented 9 years ago
size.cgi works, but I'm not happy about the load it puts on spriteme.org, and 
also
not happy about the traffic it generates requesting every image in the page. It 
would
be better to go back to the original idea and embed this functionality in
coolRunnings to return the total size of all the individual images as well as 
the
size of the resultant sprite.

Original comment by stevesou...@gmail.com on 6 Sep 2009 at 1:29

GoogleCodeExporter commented 9 years ago
OK. CooLrunnings is already downloading all the images, so it shouldn't be hard 
to
get their sizes.

Original comment by jaredhir...@yahoo.com on 9 Sep 2009 at 12:25

GoogleCodeExporter commented 9 years ago
notes to myself: When coolRunnings supports this, modify these parts of 
spriteme.js:

    updateHtml: function() {
        // TODO - This is temporary until we get height&width and size in the
coolRunnigs response.
        if ( !this.bgImages[0].width || !this.bgImages[0].size ) {
            var spriteObj = this;
            setTimeout(function() { spriteObj.updateHtml(); }, 500);

    if ( -1 === iLink ) {
        //SpriteMe_autospriteCallback();
        // TODO - Right now, there's a race condition with size.cgi. That'll go away when
        // coolRunnings returns the file size. For now, do a setTimeout.
        setTimeout(SpriteMe_autospriteCallback, 3000);

Original comment by stevesou...@gmail.com on 9 Sep 2009 at 11:50

GoogleCodeExporter commented 9 years ago
It would be cool to return three things:
  1 - total size of all the input images
  2 - size of the resulting sprite image
  3 - dimensions of the sprite image (width & height)

I'm fine if you want to return saved bytes, but I can get that from the delta 
of 1 & 2.

Original comment by stevesou...@gmail.com on 11 Sep 2009 at 5:19

GoogleCodeExporter commented 9 years ago
Here's the new json output. I can make changes to the formatting; just ask.

var coolRunnings =
{"url":"http:\/\/www.jaredhirsch.com\/coolrunnings\/public_images\/75c0e3f5e2\/g
hosts-a-plenty.png","inputSize":1209,"outputSize":794,"spriteHeight":75,"spriteW
idth":222}

Original comment by jaredhir...@yahoo.com on 11 Sep 2009 at 11:13