用 Sizzle 替换 dojo.query?

发布于 2024-12-14 21:40:00 字数 422 浏览 0 评论 0原文

与其他 JS 框架相比,Dojo 拥有最慢的选择器

我想知道是否可以在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我对此没有确切的答案,但这似乎绝对是可能的。根据dojo Ticket,这个功能已经存在很长一段时间了。

dojo 查询文档 有一个名为 Alternate Selector Engines 的部分,其中包含一个链接到 github 存储库,它似乎可以相当轻松地替换 dojo 查询引擎。

通过执行 dojo 的自定义构建,您可以自动烘焙 sizzle 引擎。如果你查看(源代码发行版)util/buildscripts/jslib/buildUtil.js,有一个用于query的参数:

"query": {
        defaultValue: "default",
        helpText: "Select a DOM query engine. Default value is the normal dojo.query engine. Using query=sizzle will use the Sizzle engine."
            + "Normal Dojo tests are not run routinely with the Sizzle engine. See dojo/_base/sizzle.js for the version of Sizzle."
    },

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 for query:

"query": {
        defaultValue: "default",
        helpText: "Select a DOM query engine. Default value is the normal dojo.query engine. Using query=sizzle will use the Sizzle engine."
            + "Normal Dojo tests are not run routinely with the Sizzle engine. See dojo/_base/sizzle.js for the version of Sizzle."
    },
茶底世界 2024-12-21 21:40:00

我质疑你的数字。 其他人对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.

难以启齿的温柔 2024-12-21 21:40:00

您不需要用 sizzle 替换 dojo.query。

你可以说dojo.query,它应该使用sizzle。

在dojo配置中

var dojoConfig = {
    selectorEngine: "sizzle",
    async: true

};

使用
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

var dojoConfig = {
    selectorEngine: "sizzle",
    async: true

};

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文