I am currently working in a project with long living pages (LLP), what makes me worry about performance and memory leaks.
Revisiting some material at MDN, I've discovered that this could lead to a memory leak:
function addHandler() {
var el = document.getElementById('el');
el.onclick = function() {
this.style.backgroundColor = 'red';
};
}
At first I did not understand why, but was easy to find a lot of explanations for this. I've found an article at codeproject, a more detailed explanation in this question and this article from Douglas Crockford.
Now my question is:
As far as I understood, this specific leak is an IE-only bug, is that correct? And, more important: until which version of our beloved blue browser from uncle Bill's company should I be worried about with this leak?
Edit:
Reliable references about the last question are desirable.
Edit #2:
Maybe I am wrong, but I think that using the 'new' standardized interface for events, we would not have the same problem:
function addHandler() {
var el = document.getElementById('el');
el.addEventListener('click', function() {
this.style.backgroundColor = 'red';
});
}
Since there is no direct assignment, I think there this solves the problem. However, this API is only IE9+, what makes me wonder if we would have the same problem with libraries' fallbacks, such as jQuery:
var $el = $('.some-el');
$el.on('click', function(){
// ...
});
I do not know enough about jQuery internals to say what this piece of code does on IE8-.