次のような繰り返しアクティブ化されるコールバックがある場合...
Template.foo.rendered = function() {
$(this.firstNode).droppable({
// other arguments
drop: function() {
// some really long function that doesn't access anything in the closure
}
});
}
次のように最適化する必要がありますか?
dropFunction = function() {
// some really long function that doesn't access anything in the closure
}
Template.foo.rendered = function() {
$(this.firstNode).droppable({
// other arguments
drop: dropFunction
});
}
この場合、rendered
コールバックは Meteor コンストラクトであり、DOM ノードfoo
が構築されるたびにテンプレートを使用して非同期に実行されます。それらのかなりの数がある可能性があります。グローバル クロージャのどこかで関数を宣言することは、Javascript エンジンが追加のローカル クロージャを追跡する手間を省くために役立ちますか?それとも問題ではありませんか?