Rafalages
Rafalages

Reputation: 1426

Image loading multiple times, Is this a Firefox ou a NivoSlider bug?

When I open two tabs with Nivo Slider in each one, I observed that firebug's net tab show multiple requisitions of the same image in each slide change. It grow the size(in mb) of the page and memory usage/allocation to firefox.exe. After a while, my computer became very slow, and memory allocation in task monitor is higher than 1gb.

How to replicate it: 1- Open http://nivo.dev7studios.com/ in 2 tabs in firefox(tested in 3.6 ~ 5.0) 2- Open net panel of firebug in the second tab 3- reload the second tab

here is the proof

Upvotes: 3

Views: 1990

Answers (4)

ZolaKt
ZolaKt

Reputation: 4721

I'm having the same problem with memory leaks. Looks like nivo isn't so great after all.

After some trying out I managed to lower the load significantly, at least according to firebug.

I did two things:

  • put display:none for all slider images in css - I don't think this actually does much, but it doesn't hurt. I was hoping this would suppres the initial load.
  • in JS, use $(document).ready instead of $(window).load- theoretically this should start the slider before all the images are loaded

The problem is still not entirely fixed, I get some strange behavior. I have just 4 pictures. They all get loaded on start. In some moment (I don't know the reason, usually first time the image is show) 2 pictures get loaded again (from cache). After that, it works fine. I left it opened for an hour, no new loads.

So in conclusion, with the mentioned changes I get 2 extra loads. Compared with what I had before (new load whenever a image is changed) its not so bad.

I still can't find the reason or the explanation for this behavior. Maybe firefox frees some memory along the way so the images get loaded again from time to time?

Upvotes: 1

Richard
Richard

Reputation: 2100

We were testing this at my job, and at first we saw Firefox re-downloading images, just as the original poster said. But then we realized something-- if you never hover over the images using Firefox's/Firebug's tool, it never redownloads the images!

So in other words, it looks like this isn't happening because of the slider. It looks like it only happens when you start investigating using Firefox/Firebug.

So I don't think this is a problem.

Upvotes: 1

user604716
user604716

Reputation: 21

I am getting memory leaks in FF 4.0.1 with one tab open. Chrome (12.0.742.100) too, although not as bad as FF.

Seems like NivoSlider is causing this leak.

Upvotes: 2

silex
silex

Reputation: 4320

I've just tested in FF 3.6 - the same issue.

Look at the file http://nivo.dev7studios.com/scripts/nivo-slider/jquery.nivo.slider.js : 84

//Set first background
slider.css('background','url("'+ vars.currentImage.attr('src') +'") no-repeat');

Also lines 253, 262, 284 etc. It adds background image on-the-fly, so the browser should request it again and again. Fortunately the server responds with header 304 Not modified.

The answer is: NivoSlider.

Upvotes: 6

Related Questions