dongpo0409 2010-12-21 00:21
浏览 96
已采纳

没有服务器访问的JQuery的GZip压缩

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!

  • 写回答

2条回答 默认 最新

  • douhoulei4706 2010-12-21 00:31
    关注

    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/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配