php - GZip Compression For JQuery Without Server Access

146

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 particular 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!

493

Answer

Solution:

You have two options

  1. 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.

  2. 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/

216

People are also looking for solutions to the problem: security - PHP Authentication

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.