GZip Compression For JQuery Without Server Access
all. I am required to build a website with each page under 130kb. I know that JQuery 1.4.4 is ~28kb when it's g-zipped, but it's 77kb minified, which is just too much for this particu开发者_运维知识库lar assignment. I have already built the entire site using JQuery in one implementation or another on each page, so scrapping it would mean days of wasted time.
With that in mind,
1) Can I add content headers to a javascript file to add "Content-Encoding: gzip" without modifying config files on the server end? I'm uploading them to the university server, but I don't have access to the configuration. From the response header, the server is: Apache/1.3.26 (UnitedLinux) mod_ssl/2.8.10 OpenSSL/0.9.6g PHP/4.2.2 mod_perl/1.27
2) From the phpinfo file, I know that ZLIB compression is enabled, but "zlib.output_compression" is not.
3) I realize this can be done using .htaccess. However, I'd like to do it any other way, if possible, since I don't want the school thinking I'm trying to modify their server configuration.
4) Will XHR's setrequestheader method work here, or is that only good for asynchronous files?
I know this is short notice and all, but my Final presentation is tomorrow, and I'll lose a ton of points if my site is over the size limit. Any help would be much appreciated!
You have two options
Use jquery hosted somewhere else that supports gzip. The file is here that you need to include http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.js This gives you a lot more advantages such as parallel downloading of files and quicker page load times.
Other options is to use PHP code to zip the jquery js and return it. Here is an example http://www.lateralcode.com/gzip-files-with-htaccess-and-php/
Use http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js, which is GZIPed.
精彩评论