jquery - Do Javascript bindings take up memory while not in use? -


I have a calendar that I have created, and the function is run when click on the calendar on one day. You can go from calendar to month to month, and it generates months as it goes. Since every day is shown on the calendar or not, using an all "days" category is bound to an event, so I'm worried about the number of "binding" in thousands of people.

  // is generated after a new month, Day TD Off ("Musudown"); TD = $ ("Table Day"); TDS ("Musudown", Teddy Mausedown);   

When I was learning C # / Monogame, I learned about the tasks that are very quick to update game elements very quickly. Therefore, I was thinking that Javascript works in the same way. Is the JavaScript engine forced to see if it has happened again and again? So some one structure like this:

  function repeat60timesPerSecond () {if (element1isClicked) {// blah} if (element2isClicked) {// blah} if (element3isClicked) {// blah} }   

Or is javascript able to actually trigger the function when the event occurs?

In short: do Javascript bindings completely take memory by existing?

My (inconclusive) research till now:

I have made many efforts on my own to answer this question. First of all, I separated from clear problems in my testing with continuity, the test did not really test this question. It was mainly tested that if the point was faster than some unknowingly, then how much storage does the actual binding take after building? I can not come in one way to test this using this test service.

Then I was walking a little bit, and found a lot of interesting things, but in clear words nothing to answer this question directly. I got the answer, which suggests using a single event in the event container in the same situation.

Update:

After posting it, I found a potential way of testing it with local JS:

  function function () {console.log ("test"); } ($ X = 1; x & lt; 1000; x ++) {$ ('# parent'). Attached ("

After the play with this (what changes for the loop, the number of iterations varies on both for the loop Is, etc.) It appears that the event binding contains very small amount of memory.

Yes, they Take all the memory, but not too much No. Only one function object is that in each element there is an indicator on that object, so it's probably like 4 byte per element.

According to Felix King's suggestion, you reduce it by using the delegation Because the container is only a compulsory for the element. However, the memory savings are offset by the increase over time - every time when the event is in the container, the handler is implemented And it is to check whether the target matches the selector.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -