replace dojo.query with Sizzle?

送分小仙女□ 提交于 2019-12-06 14:16:53

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.

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."
    },

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!