[Phpwm] [phpwm] Best js compression techniques?

Ian Munday ian.munday at illumen.co.uk
Mon Nov 30 20:01:57 UTC 2009


On 30 Nov 2009, at 16:54, David Goodwin wrote:

> Gavin Kimpson wrote:
>> Hi guys,
>>
>> I'm building a web application that is kinda heavy on the  
>> javascript -
>> and there does seem some slowdown because of it, what techniques do
>> you guys use to 'speed up' your javascript in your web-apps?
>>
>> Cheers
>
>
> a) make sure Apache / whatever gzip compresses it as it goes out
> b) make sure Apache / whatever sets good expirey headers (i.e. some  
> time
> in the future)
> c) host the JS files on a different domain name (or use e.g.  
> Google's JS
> library hosting)
>
>
> There are obviously whitespace removers/minifiers etc, but I'd expect
> them to not be all that better than e.g. mod_deflate on apache
>
> David.

As David suggests, gzip compression with Apache will probably reduce  
the data size by 70-75%.

I do use YUI Compressor to minify the code though, as a nice by- 
product is that bits of commented out code are removed and won't be  
seen by the end user.

	http://developer.yahoo.com/yui/compressor/

Combine multiple JS files into a single file / fewer files to minimise  
the HTTP requests.  This also applies to CSS files.

Make use of the suggestions made by by YSlow and the Page Speed:

	http://developer.yahoo.com/yslow/
	http://developer.yahoo.com/performance/rules.html
	http://code.google.com/speed/page-speed/

You can start to get really anal about this stuff.  I've now started  
to consistently order HTML tag attributes alphabetically "to aid  
compression" even though I know full well it'll barely make a dent!  :op

Regards,

Ian



More information about the Phpwm mailing list