压缩 HTML 和 Javascript
最近我注意到 Google 页面的源代码变得非常小。它实际上被压缩到不到 20 行(搜索“stackoverflow”的结果)。
我的假设是 Google 开发人员不会手动执行此操作。
如何自动执行此操作?如果可能的话,可以提供一些可以共享托管帐户(Apache 和 Win IIS)的东西。
谢谢。
编辑
只是为了澄清。我想弄清楚如何在服务器上安装一些插件,这将自动缩小代码(HTML,CSS,JS)。换句话说,我不想将代码复制到某些压缩算法中并粘贴结果...
要使 PageSpeed (mod_pagespeed) 工作,需要专用主机或至少 VPS 来安装它。共享托管帐户有什么可以做的吗?
Recently I noticed that the source code of Google pages became really small. It's literally compressed to less than 20 lines (search result for "stackoverflow").
My assumption is that Google Developers would not do this manually.
How to do this automatically? And if possible something that would work on sharing hosting accounts (both Apache and Win IIS).
Thank you.
EDIT
Just to clarify. I want to figure out how to install some plugin on the server, which will minify code (HTML, CSS, JS) automatically. In other words, I don't want to copy code into some compression algorithms and paste the result...
For PageSpeed (mod_pagespeed) to work, one will need a dedicated hosting or at least VPS to install it. Is there anything one can do for sharing hosting accounts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
JavaScript 的压缩器和加壳器已经推出。查看Dean Edward 的打包程序。
从 HTML 中删除空格时要小心,即
There are minifiers and packers for JavaScript already out. Check out Dean Edward's packer.
Be careful when removing whitespace from HTML - namely
<pre>
elements and elements withwhite-space: pre
. Removing extra whitespace from these element's textnodes can ruin the intended display.SmartOptimizer(php 库)或 PHP Speedy(php 脚本)应该可以满足您的需求。
SmartOptimizer (php library) or PHP Speedy (php script) should satisfy your needs.
请查看 Google Page Speed 以帮助您入门。
Take a look at Google Page Speed to get you started.
压缩 javascript: YUICompressor
Compressing javascript: YUICompressor