Question about src attribute altering

Hi. I have an image tag on my page, and I use javascript to alter the value of the src attribute (to change the image being displayed), multiple times, back and forth between (say) three images.

What I’m curious about, is whether images that previously appeared (ex. the first one) have to be downloaded once gain, or are the images stored in a cache or something once they are (intially) called on?

I’m basically wondering if having images cycle (randomly) via changing the src value will result in a constant drain on the bandwidth, or only for the initial calling of each image, and not on their repeat appearances.

Yes generally once an asset is loaded by the browser it is available via cache when re-called.

Hi @ladlon,

To see or test what @Pinegrow_User is suggesting you can open the developers tools in Chrome and click on Network, now when you load your page you see the images loading. I use https://github.com/aFarkas/lazysizes in every website I make and you can even see the images load on scroll (when they become visual for the user, because of the lazy loading).

I was not suggesting anything rather stating how browsers inherently work. By default they first review and use cache before making additional resource calls. You can review in further detail via Cache Storage in dev tools.

Does Firefox have anything like that?

Actually, I seem to remember MANY years ago, monitoring downloads and strain using something… possibly in the browser (Firefox). I have to check for that. You pulled out a memory of mine from VERY long ago. I think it was in some Developer section/menu in Firefox.

Ya, I was planning on using Javascript to randomly switch the src of an image file… which seemed like a great idea, until I suddenly realized that meant that it would be (seemingly) downloading those files over and over… so I almost abandoned that idea, until I then also realized that it probably would be cached in the browser after the initial loads, so (theoretically) wouldn’t cause any continuous bandwitch drain after the initial downloads. That’s my theory, at least… so I wanted to verify that.

UPDATE: I literally just checked the menu of Firefox after posting this, and there IS actually a Developer section, and a Network section within that. I’m not really understanding what I am seeing being displayed as a result, but it seems to be what we are all talking about. So, I guess that kind of answers that!

Don’t know what your talking about! This is a friendly users forum! Nowhere I stated that you suggested anything else then what you suggested! Did even Quote you!

When you delete your cache in the Chrome browser and open the Developer Tools and click on “Network” > “Images” then load your website you see in the Size column of the tool all the download sizes of the images from the server in the browser.

Now just load the same website one more time and under size you notice that most images are cached. When you hover over the text field you see the disc or memory cache. Enough to be sure your images are cached in the browser. For more detailed info you can go to “Application”, but fore the first impression this is enough and much easier, because you can stay on the “Network” mode.

Then why are you getting all hostile with screenshots of giant arrows trying to prove some point? I merely stated you can further see things related to cache elsewhere in dev tools.

No I don’t get hostile and just show you that my reply was containing the exact info explained in more details extracted fro your suggestion.
Do you think this is a normal reply?

Yes relative to the topic of the thread.

You obviously seem to have taken offense, but I’m not sure why?

Save your English lessons for elsewhere!

The reply I gave was accurate, maybe you have never noticed the size in the Network panel.

It’s just the way you respond.

Seems like with that last statement you already forgot your own words …

Sorry you seem to have misinterpreted a basic statement then heaped offense upon yourself and turned it into all this. That seems pretty silly to me and completely out of place.

I leave it for now. Have more important things to do.

Good luck with your arrogant attitude.

The only reason I’m on this forum is to learn something or help somebody with an issue!

Stopping with the first sentence would have made it accurate if you were actually wishing to “leave it” and move on. Instead its interesting how you chose to carry on with another attack? It’s hard to fathom how you were able to turn a basic sentence into all this.

Well hopefully @ladlon understands now that the browser will indeed cache, regardless of how a person wishes to verify this, thats just how browsers work inherently. :wink: