BBGameZone.net PBBG Network | BuildingBrowserGames | Top-PBBG
March 11, 2010, 07:09:45 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Join the forums now, and start posting to receive access to our Scripts Vault!
 
  Home   Forum   Help Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Minifying and Gzipping text files for decreased size.  (Read 87 times)
133794m3r
Level 17
*

Reputation: 1
Offline Offline

Posts: 158

Designer, Coder, Tester, Cynic, Critic.


View Profile
« on: February 07, 2010, 06:58:41 AM »

When using apache and the mod_gzip(i think that's the module's name if not whatever it's called). When you compress your files with gzip, and their extension changes to for example .js.gzip when it's called forth to the browser, does apache just automatically deflate it at once? Or does the  browser itself do it itself.  If anyone has any pages explaining how to do such a thing/wishes to explain how to do such a thing it'd be greatly appreciated.
Logged
Nox
Level 28
**

Reputation: 10
Offline Offline

Posts: 416



View Profile
« Reply #1 on: February 07, 2010, 07:09:25 AM »

Browser don't compress it, it wouldn't make sense, browser decompresses it

Common way:
Browser----request---->Server
Server----page----->Browser--->display

Server-side gzip via apache:
Browser---request---->Server
Server---gzip--->page--->Browser--decompress--->display

=> If you compress the file by yourself and save it that way (and don't use s-s gzipping), the gzip part in the last line is removed (not the "decompress" one)

However it's possible to have more layers of compression, like minified and packed file (for example JS library in shrinked version) and then s-s gzip....

It's most siginificant with JS files since they are usually large text files...the size drop is ....HUGE.
For example jQuery 1.4.1 is 156kB large (dev version), shrinked and gzipped version has final size of 23,5kB ...only 15% of total and 132,5kB less
The effect for example on image is quite minimal from what I've seen

You can view the downloaded size via Firefox's Firebug addon (Network tab)
« Last Edit: February 07, 2010, 07:56:16 AM by Nox » Logged

Bookmark worthy: Sirlin.net (game design)

jannesiera
Level 35
**

Reputation: 5
Offline Offline

Posts: 937



View Profile WWW
« Reply #2 on: February 07, 2010, 07:34:58 AM »

You can view the downloaded size via Firefox's Firebug addon (Network tab)

Just want to note that google chrome has a very nice "devtools" option for this stuff too. Just do: ctrl + shift + J

http://dev.chromium.org/devtools
Logged

dsheroh
Level 10
*

Reputation: 4
Offline Offline

Posts: 65


Perl Vicar


View Profile WWW
« Reply #3 on: February 07, 2010, 07:46:26 AM »

It's most siginificant with JS files since they are usually large text files...the size drop is ....HUGE.

The compression rates on HTML/CSS documents also tend to be excellent, as they tend to contain large amounts of repetitive text.  This site's main stylesheet, for example, gzips down from 8615 bytes to 2655, for a 70% reduction in file size.  Of course, being small to start with, it's still not that much of an overall benefit.

The effect for example on image is quite minimal from what I've seen

That's because common image file formats, such as JPEG, PNG, and GIF, are already compressed.  As an example, my current desktop wallpaper is a 1024x768 image with 24-bit color.  Uncompressed, it would be 1024 * 768 * 24 = 18,874,368 bits (2,359,296 bytes, or 2.25M).  As a .jpg, it's an 84k file.  That's about a 96.5% reduction in file size.  Smiley

If you're lucky, gzipping a compressed image file might net you another 1-2% reduction in file size - but it's at least as likely to make the file 1-2% bigger instead.
Logged
Nox
Level 28
**

Reputation: 10
Offline Offline

Posts: 416



View Profile
« Reply #4 on: February 07, 2010, 07:55:09 AM »

Thanks for adding the explanation
I mentioned JS because HTML/CSS are rather small so the absolute gain is not that big, but of course it's not bad, I compress them too

Quote
If you're lucky, gzipping a compressed image file might net you another 1-2% reduction in file size - but it's at least as likely to make the file 1-2% bigger instead.
Yes, plus you increase the overhead for the image so even if you got 1% reduction the effect would be imho rather negative
Logged

Bookmark worthy: Sirlin.net (game design)

Pages: [1]   Go Up
  Print  
 
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC
SimplePortal 2.2 © 2008-2009
Valid XHTML 1.0! Valid CSS!