So all the MooTools scripts are there, and i wanted to use gzip to serve them, as it reduces javascript sizes by two or more.
The main issue is that Godaddy uses Apache but without mod_gzip or mod_deflate. So by reading these articles on gzip compression and this Drupal use case, i finally found a solution that works.
Just put a .htaccess file in the root of the subdomain, with the content:
rewriteengine on
rewritebase /
rewritecond %{HTTP_USER_AGENT} !".*Safari.*"
rewritecond %{HTTP:Accept-encoding} gzip
rewritecond %{REQUEST_FILENAME}.gz -f
rewriterule (.*) $1.gz [L,QSA]
AddEncoding x-gzip .gz
Header set Content-Encoding: gzip
ForceType text/javascript
Then, simply login with SSH and execute this script to compress all your existing javascripts:
#!/bin/bash
cd "/your/base/folder/for/resources"
for i in `find . -name *.js`
do
echo "Compressing $i..."
gzip -c -9 $i > $i.gz
done
If it is to complicated for you, just always upload the compressed file. In example, when i upload my mycila.js file, i also upload the compressed mycila.js.gz file also.

19 comments: