无需服务器访问的 JQuery 的 GZip 压缩
全部。我需要建立一个每个页面在130kb以下的网站。我知道 JQuery 1.4.4 在 g 压缩时约为 28kb,但压缩后为 77kb,这对于这个特定的作业来说太大了。我已经在每个页面的一个或另一个实现中使用 JQuery 构建了整个网站,因此废弃它意味着浪费数天的时间。
考虑到这一点,
1)我可以将内容标头添加到 javascript 文件中以添加“Content-Encoding:gzip”而不修改服务器端的配置文件吗?我正在将它们上传到大学服务器,但我无权访问配置。从响应头中,服务器是: Apache/1.3.26 (UnitedLinux) mod_ssl/2.8.10 OpenSSL/0.9.6g PHP/4.2.2 mod_perl/1.27
2)从phpinfo文件中,我知道启用了ZLIB压缩,但“zlib.output_compression”不是。
3)我意识到这可以使用.htaccess 来完成。但是,如果可能的话,我想以其他方式进行,因为我不希望学校认为我正在尝试修改他们的服务器配置。
4)XHR的setrequestheader方法在这里起作用,还是只适用于异步文件?
我知道这是临时通知,但我的最终演示是明天,如果我的网站超出大小限制,我将失去很多积分。任何帮助将不胜感激!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你有两个选择
使用其他地方托管的 jquery
支持gzip。文件在这里
你需要包括
http://ajax.googleapis.com/ajax/libs/jquery /1.4.4/jquery.js
这给您带来更多优势
例如并行下载
文件和更快的页面加载时间。
其他选项是使用 PHP 代码
压缩 jquery js 并返回它。
这是一个例子
http://www.lattice.com/gzip-files-with- htaccess-and-php/
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/
使用 http://ajax.googleapis.com/ajax/libs/ jquery/1.4/jquery.min.js,这是 GZIP 压缩的。
Use http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js, which is GZIPed.