用 Sizzle 替换 dojo.query?
我想知道是否可以在 Dojo 中使用 Sizzle 来让 dojo.query 在幕后使用它?我认为它在 jQuery 中就是这样使用的,所以在 Dojo 中也应该可以。
找不到任何有关如何执行此操作的信息。
聚苯乙烯 链接中的测试似乎正在积极开发并且每天都会更改,因此请确保您在该页面上选择最新版本。
编辑: 测试中的数字似乎不正确,Dojo 和其他人之间的差异并不是那么根本。这使得将 Sizzle 纳入 Dojo 的任务变得不值得付出努力。
Dojo has got the slowest selectors compared to other JS frameworks.
I was wondering if it was possible to use Sizzle within Dojo to make dojo.query use it behind the scenes? I think it is used in jQuery that way, so it should be possible in Dojo too.
Couldn't find any info about how to do that.
PS
The test at the link seems to be being actively developed and changes daily, so make sure you select the latest version on that page.
EDIT: it appeared that the numbers in the test were not correct, and the difference between Dojo and others is not really as radical. That makes the task of including Sizzle into Dojo not worth the effort.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我对此没有确切的答案,但这似乎绝对是可能的。根据dojo Ticket,这个功能已经存在很长一段时间了。
dojo 查询文档 有一个名为
Alternate Selector Engines
的部分,其中包含一个链接到 github 存储库,它似乎可以相当轻松地替换 dojo 查询引擎。通过执行 dojo 的自定义构建,您可以自动烘焙 sizzle 引擎。如果你查看(源代码发行版)
util/buildscripts/jslib/buildUtil.js
,有一个用于query
的参数:I don't have a precise answer to this, but it definitely seems possible. According to a dojo ticket this feature has been in the cards for quite a while.
The dojo query documentation has a section called
Alternate Selector Engines
with a link to a github repository which appears to have a fairly easy drop in replacement for the dojo query engine.By performing a custom build of dojo, you can automatically bake in the sizzle engine. If you look at (the source distribution)
util/buildscripts/jslib/buildUtil.js
There is a parameter forquery
:我质疑你的数字。 其他人对Dojo 的查询引擎得出了相反的结论。它们都非常快,以至于可能不会产生那么大的差异。
I question your numbers. Others have come to the opposite conclusion about Dojo's query engine. They're all pretty fast, to the point where is probably doesn't make that big a difference.
您不需要用 sizzle 替换 dojo.query。
你可以说dojo.query,它应该使用sizzle。
在dojo配置中
};
使用
https://github.com/kriszyp/sizzle
正如您对任何其他 dojo 包所做的那样,
请参阅 http://dojotoolkit.org/reference -guide/1.9/dojo/query.html
You don't need to replace dojo.query with sizzle.
You can say dojo.query, it should use sizzle.
In the dojo config
};
Use
https://github.com/kriszyp/sizzle
as you would do with any other dojo package
see http://dojotoolkit.org/reference-guide/1.9/dojo/query.html