Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do image objects stay in RAM after .remove()?

I have a web-site that has a lot of large photos that are always set in the html. Like

<div><img src="sample1.jpg"></div>
<div><img src="sample2.jpg"></div>
<div><img src="sample3.jpg"></div>
<div><img src="sample4.jpg"></div>
....

This makes the web-site very slow. Even the .animate() function works with problems. So I decided to load only 5 images and the others are loaded upon request. The problem is that when too many images are loaded the web-site becomes slow again. Question:

If I use the .remove() function to remove all images around the one that is being displayed, will the images still stay in RAM, or they will be deleted and taken again from cache when I add an image?

Hope the question is clear, thanks in advance.

like image 635
Timur Gafforov Avatar asked May 19 '13 12:05

Timur Gafforov


1 Answers

You can't forcibly delete anything from the browsers active memory using Javascript/jQuery, however like the other users have said upon using .remove() the removed elements are then exposed to garbage collection.

I think its unlikely it's these images causing the slowdowns you're seeing and its more likely an issue with some of your other script code.

I'm assuming by slow down you mean like page lag indicative of memory/cpu usage.

If the issue is actual page load time then the problem lies elsewhere and has nothing to do with the RAM that's taken up but is more likely due to load times of images, if possible remove unnecessary images on server side.

like image 142
Daniel Waters Avatar answered Oct 18 '22 18:10

Daniel Waters