Javascript 筛选与查找已加载数据之间的jQuery性能测试
我已经知道“jquery.find”从当前选择器中搜索嵌套元素。但是,“jQuery.filter”只遍历已经存在的数据。根据我的猜测,过滤器会更快,但我看到很少有性能测试发现它做得更好。不知道哪条路更好,谁能帮我一下吗 假设我有这个插件: 哪种元素搜索方式更快Javascript 筛选与查找已加载数据之间的jQuery性能测试,javascript,jquery,performance,jquery-filter,Javascript,Jquery,Performance,Jquery Filter,我已经知道“jquery.find”从当前选择器中搜索嵌套元素。但是,“jQuery.filter”只遍历已经存在的数据。根据我的猜测,过滤器会更快,但我看到很少有性能测试发现它做得更好。不知道哪条路更好,谁能帮我一下吗 假设我有这个插件: 哪种元素搜索方式更快 $.plugIn = { $appForm: $("form.app-editing-page"), // means both editing and posting $appFormEdit: $("form.a
$.plugIn = {
$appForm: $("form.app-editing-page"), // means both editing and posting
$appFormEdit: $("form.app-edit"),
$appFormPost: $("form.app-post"),
$allInputs: $("form.app-post input"),
checkPerform: function(){
var visibleInputs = $.plugIn.$appForm.find("input:visible"); // way 1 with find
var visibleInputs2 = $.plugIn.$allInputs.filter(":visible"); // way 2 with filter from cached
}
}
在我看来,过滤器应该更快,因为它只从缓存的项目中查看。但是,有谁能在这方面提供帮助,了解性能
另一件事,它是声明插件和变量的正确方式
$。插件={
$appForm:[],//$(“form.app编辑页”),//表示编辑和发布
$appFormEdit:[],/$(“form.app edit”),
$appFormPost:[],/$(“form.app post”),
$allInputs:[],/$(“form.app-post输入”),
checkPerform:function(){
$.plugIn.$appForm=$(“.app编辑页面”);//比“form.class”快
$.plugIn.$appForm=$(“.app post”);
$.plugIn.$allInputs=$.plugIn.$appForm.find(“输入”);//比复杂查询快得多。
var visibleInputs=$.plugIn.$allInputs.filter(“:visible”);//更快的方法
}
}
我不知道如何进行测试。。你能帮我一下吗。