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 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)