javascript - Efficiency of .off() / .on() jQuery event handler binding combo -
I have an object, and when that object is done immediately, this is a click event handler for This object is instant when the URL changes (when the user navigates to another page). Thus, 'per page' is always a type, and as mentioned earlier, when it is changed, it is restored and the old object will no longer exist. The attached process looks like this: I am using this because I have seen that if only the event handler is attached, except for Now, I can move this attachment process elsewhere, for example in the code section where it is immediately, so it will not depend on the object and will assure that the handler will only be attached once , But it will deprive me of access to some local variables and I need to be accessible in that code section. My question is: Is the cost of it too much? I have seen some posts here, on the stack overflow, it is not optimal to emphasize it, but most examples show the code with Important note: I am using backbone.js, this is a 'one page site', objects are originally seen and they mean router. In short, no, there is no meaning to use To keep it in any other way, Not Calling & Lt; Body & gt; ; . (The process of enclosing that object with the definition)
var doc = $ (document.body); Doc.off (click on '); Doc.on ('click', function () {do_stuff ();});
.off () , the handler is a simple Clicks on fire more often as I navigate through the site (because it was attached / registered with every acceleration of that object).
.off () or inside
.on () / binding
shutdown Performance penalty for now I will not swear on the pile of bible that it is impossible for the
shutdown due to the issue of performance, but I would say that 99 out of 99 99 (99 99 99 99 or 99 99 In 10,000) In real world cases, you should never worry about closing 'A problem of performance is causing the problem.
off will never slow down the noticeable performance unless you actually do something crazy with it, or really There is a crazy site which inadvertently some really crazy with it.
Off On the other hand, many issues can be caused, display related and otherwise.
Comments
Post a Comment