How was jQuery compressed? Can we do that for Prototype?
Moderator: General Moderators
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
How was jQuery compressed? Can we do that for Prototype?
jQuery is compressed down to 20KB, which is a reasonable five seconds of load time on dialup. How was jQuery compressed and how can we compress Prototype?
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
This works...
http://dean.edwards.name/packer/
http://dean.edwards.name/packer/
It's the same script.
http://dev.jquery.com/browser/trunk/jquery/build/js/Packer.js wrote: Packer version 3.0 (beta 5) - copyright 2004-2007, Dean Edwards
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
I have a feeling prototype IS compressed - most libraries are available in 2 flavours: compressed and readable. They're functionally identical, but the "readable" prototype is there for code discovery. I would always use the compressed version in a production environment.
Oh, and Dean Edwards is The Man.
Oh, and Dean Edwards is The Man.
- AKA Panama Jack
- Forum Regular
- Posts: 878
- Joined: Mon Nov 14, 2005 4:21 pm
Or you can compress on the fly instead of relying on a javascript decompression.
http://dgrin.com/showthread.php?t=22928
And I bet gzip level 9 will compress many times better than the javascript decompression being used above. And it should be many times faster decompressing client side.
http://dgrin.com/showthread.php?t=22928
And I bet gzip level 9 will compress many times better than the javascript decompression being used above. And it should be many times faster decompressing client side.
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
- AKA Panama Jack
- Forum Regular
- Posts: 878
- Joined: Mon Nov 14, 2005 4:21 pm
Yes, servers can be setup to automatically gzip everything going out. The PHP software doesn't have to do anything as it is handled by Apache. This means even javascript, css and any other file that is loaded by the page will be compressed on the fly. No need to precompress anything. If you add in support for gzip compression on the output from your PHP program you need to check to see if Apache has the automatic gzip disabled. Do this by checking get_cfg_var('zlib.output_compression'). If it is set to false then you can gzip your output in PHP. If it is set to true then DON'T gzip your PHP output. If you do you will double compress and browsers can't handle that. 
The thing is many hosts have the library installed so PHP can use it but the servers do not have it enabled through Apache so all output is compressed. So you would have to use something similar to what I linked to to compress your CSS and javascript files on the fly.
The thing is many hosts have the library installed so PHP can use it but the servers do not have it enabled through Apache so all output is compressed. So you would have to use something similar to what I linked to to compress your CSS and javascript files on the fly.