Marco Luthe Online! » WordPress Stuff » Compressing Files To Speed Up Your Site
Compressing Files To Speed Up Your Site
As I have posted some time ago, I was not quite pleased with the speed of my blog’s loading process.
Now, I have found some ways after analysing the site with YSlow.
- As of WordPress 2.5, GZIP compression can no longer be activated in the settings, which means you have to do it on your own. You can either use Il Filosofo’s WordPress plugin GZIP Pages – or you can put the following code into your .htaccess-file (which must be supported, of course):
# Enable GZIP compression php_flag zlib.output_compression on php_value zlib.output_compression_level 2
- Done with 1., I found out that JS/CSS files were not gzipped. As the prototype javascript library is the largest JS file in WP 2.6, I compressed (shrunk) it with Yahoo’s YUI Compressor, which went very well – I haven’t found any errors using the compressed (shrunk) version so far.
Using the YUI Compressor on /wp-includes/js/prototype.js lead to a file that is now 40% smaller (71k instead of 122k).
- Although shrinking prototype helped speeding up, I still found the the JS/CSS files un-gzipped, until I stumbled upon this nice article and this one which suggest to put the following code into your .htaccess (your server must support mod_deflate):
# GZIP files <IfModule mod_deflate.c> <FilesMatch "\.(js|css|html|htm|php|xml)$"> SetOutputFilter DEFLATE </FilesMatch> </IfModule>
- The Digg JS was loaded with every post, which ended up loading the same Javascript 5 times (5 posts per page). So I banned the Digg button to show up on the single post page only.
- Last not least, I got rid of the MyBlogLog tracking code and the click tagging code, because I use Google Analytics, which should be sufficient.
The next tasks will be to get rid of unused CSS elements, shrink some more CSS/JS files, remove annoying sidebar boxes – and finally, a cleanup of the whole template code.
[Update from 2008-10-10]
OK, I admit, I am kind of stupid sometimes: with every WordPress update, I lose the packed prototype file, because I delete wp-includes completely. So, as a reminder: WITH EACH WP UPDATE, PACK PROTOTYPE AGAIN! This is safer than putting in the formerly packed prototype.js every time, because you never know what might have been changed. Hope I will remember…
[Update from 2009-04-23]
The PHP Speedy WordPress Plugin also helps to speed up your site by joining JS- and CSS-files into one single file each (i.e. one JS-file and one CSS-file instead of maybe a dozen).
Filed under: WordPress Stuff · Tags: .htaccess, apache, cleanup, code, compress, compression, compressor, css, deflate, file, gzip, javascript, mod_deflate, plugin, prototype, script, speed, stylesheet, wordpress, yslow, yui
-
http://www.askapache.com/ AskApache
-
Kyn
-
http://www.saphod.net Marco











