“the j stands for Juwise”
about me | research blog | wordpress plugins | jQuery plugins

25 July, 2010

Enabling compression with GoDaddy Shared Hosting

Compression of HTML, CSS and JavaScript is quite important for improving your site’s speed and should always be used.

Of you will find that all you need to do is add a line similar to the following to your .htaccess file:

AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml application/x-javascript text/javascript application/javascript
Source: StackOverflow

However, if you’re on a GoDaddy shared hosting account you may have realised that this doesn’t work. GoDaddy’s help page recommends that you paste this code in all your PHP pages:

<?php if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start(); ?>

That’s fine, but from my understanding this will not cache your CSS or JavaScript. However, I found a solution here here, which involves some .htaccess trickery to compress all your CSS and JavaScript files automatically. Enjoy!