¿La verificación de la función existente impide que la recolección de elementos no utilizados del navegador libere memoria?

I have JavaScript in file A which loads file B (through a jquery AJAX load) into element X. On success, file A calls resizewin (below) which checks if the function resizeContent exists (which was in B), and if so executes it. File A then removes DOM element X.

function resizewin() {
  if (typeof(resizeContent) === 'function') resizeContent();
}

In chrome I see detached DOM tree elements (well after I .remove() the X element). I'm trying to track down the cause. Could the above be the cause? In other words, does checking if a function exists in the element and then calling that function prevent the browser garbage collection from deleting element X even after it is removed from the DOM?

If so, what is the right way to do this?


EDIT: Adding more code as requested. Here is how I load B into the DOM (from file A):

$.ajax({
  type: 'POST',
  contenttype: "application/html",
  dataType: 'html',
  url: url,
  data: dataarr,
  success: function(response) { $('#'+element).html(response); }
});    

and in file B my function:

function resizeContent() {
  console.log("In resizeContent");
}

preguntado el 05 de mayo de 13 a las 14:05

“…does checking if a function exists in the element and then calling that function prevent the browser garbage collection from deleting element X even after it is removed from the DOM?” No. Can you show more code? -

I think it does. When a loaded a new element via jaxa containing a function called resizeContent the old deteched element seemed to dissappear. I think...but would love to hear an informed view -

0 Respuestas

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.