So I am making a complex project management system that is build completely in AJAX. With hash navigation the site loads and removes a lot of HTML and adds a lot of event listeners on each load.
My question is, does modern browsers garbage collect the event listeners after those elements have been $.remove’d.
If not, is it better to use onclick=”doFunction();” instead to prevent adding event listeners? I rather not do it this way, but if it will prevent memory leaks it might be the best option.
Any help would be greatly appreciated.
Thanks!
No, it is better to add event listeners using jQuery, because jQuery deals with possible memory leaks.