[译]OptimizeHTML:优化HTML文件的工具
By robot-v1.0
本文链接 https://www.kyfws.com/applications/optimizehtml-a-tool-to-optimize-html-files-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 5 分钟阅读 - 2277 个词 阅读量 0[译]OptimizeHTML:优化HTML文件的工具
原文地址:https://www.codeproject.com/Articles/594/OptimizeHTML-A-Tool-to-Optimize-HTML-Files
原文作者:Paolo Messina
译文由本站 robot-v1.0 翻译
前言
A simple script to reduce the size of a HTML source
一个减少HTML源代码大小的简单脚本
This little VBScript application strips unneeded characters from your HTML files.
这个小VBScript应用程序从HTML文件中删除不需要的字符.
介绍(Introduction)
如今的HTML编辑器非常易于使用,它们支持可视化编辑以及HTML源代码的语法高亮显示和自动格式设置,以使初学者和高级用户都感到满意.但是诸如自动缩进之类的事情会使文件越来越大,因此您可能希望减少页面的下载时间.它来了,这个小脚本.(Today’s HTML editors are very easy to use, they support visual editing as well as syntax highlighting and auto-formatting of HTML source, for both the beginner and the advanced user’s happiness. But things like auto-indenting make your files bigger and bigger, so that you may want to reduce the download time of your pages. Here it comes, this little script.)
这个小VBScript应用程序从HTML文件中删除不需要的字符.结果不便于再次编辑,因此此脚本应用作上载之前的最后一步.但是,将文件重新加载到您喜欢的自动格式编辑器中应该会使它再次回到其先前状态.(This little VBScript application strips unneeded characters from your HTML files. The result is not handy to edit again, so this script should be used as the last step before uploading. However, reloading the file into your favorite auto-formatting editor should bring it again to its previous state.)
优化HTML使用(OptimizeHTML Usage)
有几种使用此脚本的方法:(There are several ways to use this script:)
-
您可以双击它或从命令行管理程序执行.(You may double-click on it or execute from the Shell.)将出现主对话框,要求一些文件进行优化.您可以指定绝对路径或相对路径.如果路径的文件名部分是"(The main dialog will appear asking for some files to optimize. You may specify either an absolute or a relative path. If the filename part of the path is a ‘)()**'(星号)字符,它将处理所有(’ (asterisk) character, it will process all the).htm(.htm*)和(and).html(.html)*给定目录(当前目录,如果未指定)中的文件.它不会递归子目录.(files in the given directory (current directory, if none is specified). It will not recurse subdirectories.)
-
您可以在上面放一些文件或提供命令行参数.(You may drop some files on it or give command line arguments.)该程序将处理每个删除的文件(或从命令行).(The program will process each file dropped (or from the command line).)
如果要处理多个文件,脚本将要求确认.(If more than one file is to be processed, the script will ask for confirmation.)
您可以个性化程序的行为甚至语言.这些是可替代的选项:(You may personalize the program’s behavior and even the language. These are overridable options:)
REMOVE_COMMENTS
删除其中包含的注释(removes the comments enclosed in the)**<!-- -->**
标签(tag)REMOVE_PROGID
删除(removes)**<META NAME="GENERATOR" ... >**
和(and)**<META NAME =" ProgId" …>(<META NAME=“ProgId” … >)**标签(tags)MAKE_BACKUPS
制作每个处理过的文件的备份副本,并附加一个(makes a backup copy of each file processed, appending a).bak(.bak*)*到文件名(*to the filename*) 这些是可本地化的字符串:(*And these are the localizable strings:*)
Const INPUT_FILE = "HTML file to optimize:"
Const INPUT_TIP = "Tip: 'path\*' means all .htm .html files" & _
" in given path (default is current path)"
Const PROCEED_MSG = "Optimization of all .htm .html files in folder:"
Const PROCEED_ASK = "Proceed?"
Const PROCEED_CMD1 = "Optimization of "
Const PROCEED_CMD2 = " files from command line."
Const COMPLETE_MSG = "Optimization completed."
Const ERR_NOTFOUND = "File does not exist."
您可能希望创建一个快捷方式(You may wish to create a shortcut to)*OptimizeHTML.vbs(OptimizeHTML.vbs)*在你的(in your)*发给(SendTo)*目录,它将优化您发送到该目录的所有文件.(directory and it will optimize all the files you send to it.)
有关HTML验证和优化的更多信息(More on HTML Validation and Optimization)
如果您想进一步了解HTML和相关技术,则必须访问以下站点:(If you want to know more about HTML and related technologies, this is a site you must visit:) 万维网联盟(The World Wide Web Consortium) .(.)
您也可以看看(You may also take a look at the)**W3C开源软件(W3C Open Source Software)**在同一页面上并尝试(in that same page and try the good) HTML整洁(HTML Tidy) Dave Ragett编写的实用程序.这是他页面的摘录:(utility by Dave Ragett. Here is an excerpt from his page:)
- “在编辑HTML时,很容易犯错误.如果有一种自动解决这些错误并将整齐的编辑内容整理成布局合理的标记的简单方法,那不是很好吗?好了!Dave Raggett的HTML TIDY是这是一种免费的实用工具,它在专门的HTML编辑器和转换工具所产生的难以阅读的标记上也非常有用,并且可以帮助您确定在使残疾人更容易访问您的页面时需要进一步关注的地方. “(“When editing HTML, it’s easy to make mistakes. Wouldn’t it be nice if there was a simple way to fix these mistakes automatically and tidy up sloppy editing into nicely laid out markup? Well now there is! Dave Raggett’s HTML TIDY is a free utility for doing just that. It also works great on the atrociously hard to read markup generated by specialized HTML editors and conversion tools, and can help you identify where you need to pay further attention on making your pages more accessible to people with disabilities.") 如果您想验证HTML页面,则可以使用(If you want to validate your HTML pages, you may use the) HTML验证服务(HTML Validation Service) ,始终来自W3C网站.(, always from the W3C site.)
结论(Conclusion)
我希望您会发现此脚本对HTML编辑有用.请注意,此脚本仅会删除指定文件中的某些字符,因此无法验证它们.(I hope you will find this script useful for your HTML editing. Please, note that this script only strips some characters from the specified files, it can’t validate them.)
如果您改进了代码,请让我知道并将其提供给其他人.对于任何意见,建议或批评,请使用下面的空白.(If you improve the code, please let me know and make it available to other people. For any comments, suggestions or critics, use the space below.)
执照(License)
本文没有附带任何明确的许可,但可能在文章文本或下载文件本身中包含使用条款.如有疑问,请通过下面的讨论区与作者联系.(This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.)
可以找到作者可能使用的许可证列表(A list of licenses authors might use can be found) 这里(here) .(.)
许可
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。
C++ Dev 新闻 翻译