Topic: Compressing CSS and JS
Can it cause any problems letting the httpd server compress CSS and JS files, or should they as a matter of course be compressed?
Cheers.
You are not logged in. Please login or register.
PunBB Forums → General discussion → Compressing CSS and JS
Can it cause any problems letting the httpd server compress CSS and JS files, or should they as a matter of course be compressed?
Cheers.
I'm not bumping, honest. Been searching the web again regarding this, and I believe the answer is it's safe to do so nowadays? T'would appear old Netscape 4 was the main problem with doing this in the past? I've not been able to find any references to anything later having problems, but would still rather have a second opinion before I go ahead and attempt it.
Cheers again,
Matt
I never had any issues with it. My main hosting (and my old main one, too) do gzip almost everything on the fly (including all html, xml, css, js for sure... I think it skip it for images, video, and the like). If your UA can't handle it, there's a mechanism that take care of it (it doesn't get sent gziped).
Frankly, a server that doesn't gzip most files nowadays... not a good server. From the server point of view, it's mostly a good thing : a little more cpu for much less bandwidth, and faster transaction closing. From the user point of view, it's all beneficial... pages load much more faster.
The only case I can think of where someone might consider not doing it, would be if he had a dedicated box already cpu limited and more bandwidth (and I mean, like 50 to 200% more) available for free. That may seems as a good trade off for him, but he would only slightly delay a needed cpu upgrade, and punish his users. And with cable and some dsl subscriber having download quota in some countries, it's very much unpleasant to them.
Gzipping it is absolutely no problem.
Cheers. I already have it gzipping the html files and such, but for some reason, (and I'm sure it was due to some IBM techinfo), got it into my head that the CSS and JS should be left as is. Thought it seemed a bit silly not compressing them though.
Been trying to get rid of any excess of late, (or make any fancy features all on/off selectable at a minimum in the profile, as with smilies and such), so started wondering about those two sets of code again.
Thanks ever so much for the advice gents. Greatly appreciated.
Matt
I have to say that I don't really see the benefit of compressing CSS, considering that they'll get cached client-side anyway and will remain so even if the page linking to it gets changed.
You'll still save bandwidth.
Especially useful if you're running MediaWiki or so, that CSS is huge.
I have to say that I don't really see the benefit of compressing CSS, considering that they'll get cached client-side anyway and will remain so even if the page linking to it gets changed.
It depends on how many uniques you have. If you have 1000 unique visitors and a 10 KB stylesheet, that's 10 MB of bandwidth for stylesheets. If compression takes it down to 5 KB, that's 5 MB of bandwidth instead. Now, how about if you have 10,000 or 100,000 unique visitors? How about if some of those visitors have caching disabled?
As Bekko said, MediaWiki's CSS can exceed 30 KB.
CodeXP wrote:I have to say that I don't really see the benefit of compressing CSS, considering that they'll get cached client-side anyway and will remain so even if the page linking to it gets changed.
It depends on how many uniques you have. If you have 1000 unique visitors and a 10 KB stylesheet, that's 10 MB of bandwidth for stylesheets. If compression takes it down to 5 KB, that's 5 MB of bandwidth instead. Now, how about if you have 10,000 or 100,000 unique visitors? How about if some of those visitors have caching disabled?
As Bekko said, MediaWiki's CSS can exceed 30 KB.
Oh I do understand what you're saying, but I just don't think it's worth it in most cases. In cases of extreme traffic I'd think you'd run into other resource problems before you'd reach any bandwidth limits anyway.
I recently wrote a mod_perl output filter which sits inside Apache. It intercepts requests for .css files and then “compresses” them on the fly before sending. It’s not gzip compression, what it does is strip whitespace, comments, newlines etc. Check it out here: Compressing CSS on the fly
PunBB Forums → General discussion → Compressing CSS and JS
Powered by PunBB, supported by Informer Technologies, Inc.