I have a theory question about what happens when you have jQuery to search for elements / snap to elements that do not exist on the page.
For example, I have a javascript file that contains many Click events, however on some pages these click events are not used. Instead of creating multiple javascript files and having duplicate code, I reduced most of my code to a single file.
$('#target').click(function() { alert('Handler for .click() called.'); });
Basically, to bring my paragraph to a few simple sentences. What happens when id "target" does not exist? How does jquery handle such a case?
Now that I am working on my website, it seems that FireFox's memory usage is growing like crazy. Not sure if itβs just FireFox or not, but if I donβt have an element on the page, it causes a memory leak by binding to elements that do not exist?
Just curious what happens behind the scenes.
Thanks!
source share