I am developing more and more high-level applications using JavaScript / jQuery. I tried to learn more about JavaScript and dive into some of the more complex features. I just read an article on memory leak when I read this section of the article.
JavaScript is a garbage collection, meaning that memory is allocated to objects when they are created and restored by the browser when there are no more links to them. Although there is nothing wrong with the JavaScript garbage collection mechanism, this contradicts the way some browsers handle memory allocation and recovery for DOM objects.
It made me think about some of my coding habits. For some time, I was very focused on minimizing the number of requests that I send to the server, which I consider to be just good practice. But I wonder if sometimes I havenβt gone too far. I am very unaware of any performance issues / bottlenecks that come with the JavaScript language.
Example
I recently created an application for managing a towing company. I used the jQuery UI dialog box widget and populated the datagrid with specific ticket data. Now it sounds very simple on the surface ... but there are a lot of them.
(and now for the question ... drum please ...)
I am wondering what are the pros and cons for each of the following options.
1) Make only one request for this ticket and save it permanently in the DOM . Just showing / hiding the modal window, this means that only one request is sent per ticket.
2) Fulfill the request every time the ticket is open and destroys it when it is closed.
My natural tendency was to store tickets in the DOM , but I am worried that this will eventually start to punish a ton of memory if the application lasts a long time without being reset (which will).
I'm really just looking for the pros and cons for both of these options (or something neat that I haven't even heard of = P).
source share