减少 HTML 占用空间的好工具?
有谁知道可以在页面上运行的好工具(例如,对于 asp.net)以帮助最小化页面的占用空间大小?
该页面将包含典型的项目:HTML、Javascript 等。
我过去听说过 Javascript 粉碎机,这将使代码的大小尽可能紧凑(我想,并混淆它)。
目标是帮助优化页面大小(为了速度而使其尽可能小,而不进行任何更改)。
这可能吗?
Does anyone know a good tool that can be run on a page (for asp.net, for example) to help to minimize the footprint size of the page?
The page will have typical items: HTML, Javascript, etc.
I've heard of Javascript crunchers in the past, that will make the size of the code as compact as possible (and obfuscate it, I suppose).
The goal is to help optimize the page size (make it as small as possible for speed, without changing anything).
Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您可以将 Web 服务器配置为动态压缩页面(并可能缓存压缩版本),以便任何客户端指示它可以采用 gzip 或 zip(或其他)编码,这几乎是所有这些编码。
You could configure your web server to compress the page on the fly (and possibly cache the compressed version) for any client that indicates it can take a gzip or zip (or other) encoding, which is pretty much all of them.
嗯,它不是一个自动清理工具,但我喜欢 YSlow 来优化页面。 YUI 压缩机 可以缩小您的 JavaScript。
如果您真的对 javascript 感兴趣,关键字是“minify”。
另外,看看刚刚发布的这个问题:HTML 和东西
希望有帮助!
Well, its not a automatic cleaner-upper, but I like YSlow for optimizing pages. And the YUI Compressor can minify your javascript.
If you're really interested in javascript, the keyword is "minify".
Also, look at this question just posted: HTML and stuff
Hope that helps!
是的,绝对是。 我不是 ASP.NET 人员,但您可以寻找一些东西(正如其他人所说):
服务器选项
缩小 JavaScript 选项,
反过来又可以被 gzip 压缩为
出色地。
就像javascript一样,也可以
被压缩。
我们的 Java 应用程序使用 pack:tag。 也许您可以找到类似的 .net 替代品。
已经提到过,Yslow 可以显示您可以做出哪些改进。
Yep, definitely. I am not an asp.net guy, but things you could look for (as others have said):
server option
minifying options for javascript,
which in turn can be gzipped as
well.
just like javascript, and can also
be gzipped.
Our java apps use pack:tag. Maybe you could find a similar .net replacement.
Yslow, already mentioned, can show what improvements you can make.
搜索一些 ASP .NET 压缩技术,如果您使用的是 IIS6,我建议您MbCompression,但是如果你运行的是 IIS 7,它有很棒的内置 HTTP 压缩支持,您可以根据配置文件中的 MIME 类型定义压缩哪些文件。
Search for some ASP .NET Compression techniques, if you're on IIS6 I recommend you MbCompression, however if you're running IIS 7 it has great built-in HTTP compression support, you can define which files get compressed based on their MIME type in your configuration files.
我个人不会为了大小而牺牲可读性和可维护性。
动态 Web 服务器压缩为我节省了很多(考虑到文本压缩效果非常好),而进一步的优化对我来说却收效甚微。
I personally would not sacrifice readability and maintainability for size.
Dynamic web server compression saved me a TON (given text compresses so well), and further optimization would have gained me very little.
一些基础知识:
IIS 将 JS/CSS/Html 文件的压缩响应保存在磁盘上,因此,后续对 JS/CSS 的请求将从磁盘提供服务(绕过压缩步骤)。 虽然 ASPX/ASCX 的压缩响应不会缓存在磁盘上,因为响应因请求而异。
因此,最佳实践是将 Javascript/CSS 保留在自己的文件中,并避免将内联 CSS/脚本放在 aspx/ascx 中。
一般来说,有两种方法可以减少页面大小/HTML
1) 通过webserver/HTTPModule压缩
[启用 IIS 6 HTTP 压缩][1]
2) 通过第三方工具进行混淆/压缩 - JASOB 是我最喜欢的一个。
它还可以压缩/混淆 php/asp.net/perl/jsp/XSLT 文件中的 javascript/css 代码。 如果像 vanila DOS 一样,那么也有命令行界面。
我已经在几个 ASP.NET 项目中使用了它,我只需选择我的 webproject 目录,JASOB 提供了很好的选项来发布 webproject 目录的模糊版本。 这意味着它会混淆 webproject 目录下所有文件中的 javascript/css,并且它也会遍历子目录。 所有这一切都只需一键完成。
希望能帮助到你,
毛里克·莫迪
http://www.jasob.com/Features.html
[1]: - http://msmvps.com/blogs/omar/archive/2006/08/10/iis-6-compression-quickest-and- effective-way-to-do-it- for-asp-net-compression.aspx
A bit of fundamentals:
IIS saves compressed response of JS/CSS/Html files on disk so, subsequent requests for JS/CSS is served from Disk(bypassing step of compression). While compressed response for ASPX/ASCX are not cached on disk, since response varies from request to request.
Therefore, Best practise is to keep Javascript/CSS in their own files and avoid putting inline CSS/Script in aspx/ascx.
Broadly there are two ways to reduce Page-Size/HTML
1) Compression by webserver/HTTPModule
[Enable IIS 6 HTTP Compression][1]
2) Obfuscation/compression by third party tool - JASOB is my favourite one.
It can also compress/obfuscate javascript/css code from your php/asp.net/perl/jsp/XSLT file. And If like vanila DOS then there's command line interface too.
I have used it in several ASP.NET projects, I just select my webproject directory and JASOB provides nice option to publish obfuscated version of webproject directory. This means it obfuscates javascript/css from all files lying under your webproject directory and yeah it traverses sub directories too. And All of this in one click.
Hope it helps,
Maulik Modi
http://www.jasob.com/Features.html
[1]: - http://msmvps.com/blogs/omar/archive/2006/08/10/iis-6-compression-quickest-and-effective-way-to-do-it-for-asp-net-compression.aspx