Honored to be a part of the YUI project, I am now helping with the maintenance of the CSSMin part of the YUICompressor. My changes are now part of the trunk on github, so I'm official. Next on the agenda is documenting the thing, so that's what I'll try to do here, maybe in a few posts. You know, divide and conquer.
有幸成为一部分YUI项目,我现在与维护CSSMin部分帮助的YUICompressor 。 我的更改现在是github上的一部分,所以我是官方的。 议程上的下一个步骤是记录下来,这就是我在这里可能会尝试做的事情,也许是在几篇文章中。 你知道,分而治之。
PHP,Java和JavaScript端口 (PHP, Java and a JavaScript port)
Originally written in PHP by Isaac Schlueter and ported to Java by Julien Lecomte, CSSMin got a JavaScript port by yours truly some time ago. Because, after all, JavaScript is the language of the web, isn't it?
CSSMin最初由Isaac Schlueter用PHP编写,并由Julien Lecomte移植到Java,实际上在一段时间之前,CSSMin就获得了JavaScript移植。 因为毕竟JavaScript是网络的语言,不是吗?
You can play with the latest git version of the JS port online here.
I'm also happy to report that the JS port is now used in PageSpeed and YSlow (as you probably know Firefox extensions are written in JavaScript)
我也很高兴地报告JS端口已在PageSpeed和YSlow中使用(您可能知道Firefox扩展是用JavaScript编写的)
建造 (Building)
If you want to play on your own with the source version of YUICompressor without waiting for the next release, you can build it like so:
如果您想独自使用源代码版本的YUICompressor播放而无需等待下一个版本,则可以这样构建:
Checkout or download the code from http://github.com/yui/yuicompressor/
Navigate to the root
yuicompressor/
directory导航到
yuicompressor/
根目录Type
ant
and hit enter输入
ant
并按Enter
In order for this to work you need a somewhat recent Java SDK installed and also Ant running. (On the Mac, just do port install apache-ant
to get Ant)
为了使其正常工作,您需要安装一些最新的Java SDK并运行Ant 。 (在Mac上,只需执行port install apache-ant
即可获得Ant)
This is for the Java version, the JS version needs no building, of course.
这是针对Java版本的,而JS版本当然不需要构建。
测验 (Tests)
There's a bunch of new tests now (and if you want to contribute to the project, you can always write more tests and test cases for any bugs), you can run them with the suite script that Isaac wrote:
现在有很多新测试(如果您想为项目做贡献,您可以随时编写更多测试和测试用例来解决任何错误),可以使用Isaac编写的套件脚本来运行它们:
cd tests/
cd tests/
./suite.sh
./suite.sh
One thing I added (and loved it) is to run the tests using the JS port as well. Since the JS min part is using Mozilla's Rhino (slightly modified), Rhino is part of the code. So I'm using this already available JavaScript interpreter to run the JS port. Convenient.
我添加(并喜欢)的一件事是也使用JS端口运行测试。 由于JS min部分使用的是Mozilla的Rhino (稍作修改),因此Rhino是代码的一部分。 所以我正在使用这个已经可用JavaScript解释器来运行JS端口。 方便。
The procedure to write new tests is simple:
编写新测试的过程很简单:
Create source CSS file in the
tests/
directory, e.g.new-test.css
在
tests/
目录中创建源CSS文件,例如new-test.css
Create a new file with the expected result and name it with a
.min
extension, e.g.new-test.css.min
创建具有预期结果的新文件,并以
.min
扩展名命名,例如new-test.css.min
You can use the handy-dandy online version to help with the tests creation.
您可以使用便捷的在线版本来帮助创建测试。
下次 (Next time)
With those details out of the way, the next time I'll talk more about the different things that CSSMin does to your CSS code. Thanks for reading!
有了这些细节,下一次我将更多地讨论CSSMin对您CSS代码所做的不同操作。 谢谢阅读!
Tell your friends about this post on Facebook and Twitter
在Facebook和Twitter上告诉您的朋友有关此帖子的信息