PDA

View Full Version : gzip your CSS


hidjra
17 Mar 2006, 00:06
Step 1
Create a new file, call it 'gzip-css.php' copy the following snippet and upload to the 'vbulletin_css' folder:



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



Step 2
create a .htaccess file, put this in the same directory as above, put in the following snippet:



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



Step 3
Open the adminfunctions_template.php file located in the 'includes' directory. Look for the following:



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



change it to



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



Now login to you vb control panel, re-generate the css file and your done. Enjoy ;)

daklay
17 Mar 2006, 00:56
FIRST POST


Awesomse idea man :banana:

Andreas
17 Mar 2006, 01:04
IMHO it would be easeir to just use mod_gzip ?

yinyang
17 Mar 2006, 03:30
what's this for?

aladinliverpool
17 Mar 2006, 04:34
its for gzip'ing your CSS!

like gzip'ing up your coat when its chilly. ;)

Zia
17 Mar 2006, 06:44
umm gzip css ?
confused... it should help to load the page faster ?

mod_gzip ..its possible to use it in shared server?

Zachery
17 Mar 2006, 17:50
Hmm, I wouldn;'st suggest that, at least if I understand some things. I believe that IE has some issues cacheing gziped pages, and the CSS file should only be requested a few times before cached, thus why we have it as a file.

Snake
17 Mar 2006, 18:56
Thanks!

Zia
17 Mar 2006, 19:05
and the CSS file should only be requested a few times before cached, thus why we have it as a file.

that means this edit will make the css "save as files" ???!!

this option allready in vb's acp.

goyo
17 Mar 2006, 19:52
that means this edit will make the css "save as files" ???!!

this option allready in vb's acp.

No... this means your server zipping up your .ccs file before sending to your browser. Thus less bandwidth usage... although I don't see the real point of this hack as .css files downloaded only once or twice than stored for weeks/months (if no changes in .css sizes) by all modern browsers.

Zia
19 Mar 2006, 08:48
hmm then no need to use this att all....

HeRCuL70
21 Mar 2006, 01:04
is it working at winodws servers?

briansol
24 Apr 2006, 08:16
is step 3 bakwards?

I had .css in there, not .php

Hemanth
24 Apr 2006, 08:45
Good work..

But is there any increase in performance?

Zachery
24 Apr 2006, 09:30
Increase preformace would be removing gzip, decreasing preformance would be adding it back.

El-Gazaly
07 May 2006, 04:09
This code
$cssfilename = 'clientscript/vbulletin_css/style-' . substr(md5(microtime()), 8, 8) . '-' . str_pad($styleid, 5, '0', STR_PAD_LEFT) . '.css';
is in file alreadey
and iam not editing it before

Code Monkey
07 May 2006, 05:43
This is pointless since browsers cache all css and javascript when they are seperate files. It IS why you should always have them in a seperate file. Most webservers are running mod_deflate or equivilents that compress text in a way that browser can interpret. Browsers check and compare the time and date of last update for css and javascript files before downloading. So unless you have changed the css file, they will not be downloading the css in the first place.

But, do as you please.

ShiningArcanine
14 Jun 2006, 22:03
Personally, I think gzipping css files will not add as much bandwidth savings as gzipping .php files would but more bandwidth savings and faster initial page loads make doing something like this worth it.