Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Author Topic: Compressing CSS files by Gzip  (Read 2376 times)

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Compressing CSS files by Gzip
« on: April 17, 2007, 06:48:30 pm »

Tryin' to make Brauck's trick working out (I didn't succeed) to compress CSS, I found another interesting trick.

As I have 2 separate heavy CSS files I usually call them by adding in Head :
Code: [Select]



...
The solution found is to have those files combined and compressed by Gzip.
So you only have on line in your index file :
Code: [Select]
And in the css folder I've put that index.php file :
Code: [Select]
header("Content-type: text/css; charset=UTF-8");
ob_start('ob_gzhandler');
include "miseenpage.css";
include "formulaires.css";
include "pageaccueil.css";
ob_end_flush();
?>
It works. Now I gonna try to compress them twice. :)

piXelatedEmpire

  • MIA
  • ULTIMATE member
  • ******
  • Karma: 37
  • Posts: 1401
  • currently MIA
Compressing CSS files by Gzip
« Reply #1 on: April 18, 2007, 01:18:14 am »

Does this provide any real benefits? I mean, how big are your css files to begin with?
Wouldn't this just put strain on the CPU using gzip?

*playing devil's advocate* :D
Logged
my apologies to the sNews crew, but I will be MIA for the forseeable future

lessismore

  • Jr. Member
  • **
  • Karma: 0
  • Posts: 67
Compressing CSS files by Gzip
« Reply #2 on: April 18, 2007, 02:11:02 am »

Quote from: piXelatedEmpire
Does this provide any real benefits? I mean, how big are your css files to begin with?
Wouldn't this just put strain on the CPU using gzip?

*playing devil's advocate* :D
Good point - I originally saw the compression idea and thought ... cool.

However, I bet the ob commands are probably more overhead than gzipping a tiny ASCII file - hope I'm wrong as I use the ob commands too.

If the CSS comments approach the size of Tolstoy's W&P it might be worth it though.  :cool:
Logged

Joost

  • Guest
Compressing CSS files by Gzip
« Reply #3 on: April 18, 2007, 07:12:25 am »

Quote from: piXelatedEmpire
Does this provide any real benefits? I mean, how big are your css files to begin with?
Wouldn't this just put strain on the CPU using gzip?

*playing devil's advocate* :D
 = 16,4 kB  But it is worth every bit, take a look.


 :)
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Compressing CSS files by Gzip
« Reply #4 on: April 18, 2007, 09:03:44 am »

That's WAS real s**** !
It seems some browsers didn't like the compressed CSS they received.
Quote from: lessismore
If the CSS comments approach the size of Tolstoy's W&P it might be worth it though.  :cool:
:D