views:

19

answers:

1

Coming from flash it was always necessary to drop bitmap data in my slideshows so that I wasn't just loading more and more data into memory and thus weighing the program down.

Now that I've started building these slideshows using jQuery, I'm wondering if I should be cognizant of the same issue.

For instance, it's easy to keep appending images to a div, burning through arrays until the cows come home. But, I'm wondering if I should be removing the covered up images in the mean time or is my browser smart about layered bitmaps.

Thoughts?

A: 

You should remove the divs that are not visible (or some other logic) from the DOM, otherwise it will keep growing. Your browser only knows about element in the DOM, if the element is attached to the DOM it needs memory to retain it.

Dani Cricco
Elements that are not in the document structure are still, technically, in the DOM. For instance, if you just do `document.createElement('tagName')`, but never append the element to a parent in the document structure, it will still consume memory for the lifetime of the page.
eyelidlessness
@eyelidlessness. If the tag doesn't contain an internal scripting object it won't leak. It is safe to do document.createElement("div"), but is unsafe to do document.createElement("<div onClick='foo()'>"
Dani Cricco