Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7511715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:38:14+00:00 2026-05-29T23:38:14+00:00

Maybe a silly question but here goes anyway. Example: Let’s say I have one

  • 0

Maybe a silly question but here goes anyway.

Example: Let’s say I have one non-looping animated GIF and I have two img elements.

<img src="" id="slot1" />
<img src="" id="slot2" />

So I use a little javascript to change the source of the slot1.

function changE(x)
{var image=document.getElementById (x);
 image.src="animated.gif";
}

someButtonGotClicked=changE('slot1'); 

that works fine. Gif plays from start to end but if I then change the src of slot2 to the same gif:

changE('slot2');  

slot1 resets it’s gif back to the start to sync with slot2 starting it’s gif.

Now i’m aware I could copy the gif and have 2 seperate files to use and I know about sprite sheets but I’m curious If I can use one copy of a gif and have it used multiple times on a page without all instances of the gif being restarted everytime another img element recieves the same file as it’s src?

Hope that wasn’t confusing. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T23:38:17+00:00Added an answer on May 29, 2026 at 11:38 pm

    Once an image is loaded in memory, all other objects that request that image, using the same URL, get a reference to the image from the browser cache. This avoids loading the same image multiple times. In the case of a gif, one of the meta data to be kept track of is the current frame, which is stored not at the <img> dom element, but rather at the browser level in the structure it uses to store that gif.

    On load, that frame index is reset. So, while the browser is processing the gif loop, a second image loading sets the current frame index to the beginning, hence both images synchronize.

    This is a browser implementation, and it seems most browsers follow this implementation. One advantage to this is that if you have thousands of little gifs (from the same URL) in one page, the browser would do a lot less computation to render them, because it would only change one frame index, not thousands.

    Edit:
    To fix your code you’d have to basically add something random at the end of your image.

    function changE(x)
    {var image=document.getElementById (x);
     image.src="animated.gif?" + Math.random();
    }
    

    So the browser thinks this is a different image (i.e. different URL).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok so this maybe a simple/silly question but I don't know so here goes:
So, maybe a bit of a silly question, but say I have several models
Maybe silly question to the JS gurus and ninjas out there but here goes:
I have one query. Maybe it is a silly question but still I need
This may be a silly question but... Say you have a sentence like: The
Silly question, but say you have class Foo: class Foo { public: typedef boost::shared_ptr<Foo>
Maybe a silly question, but where do I fill in this URL? I have
This may be a silly question but... Say I have a String like 4e59
Maybe this question is kind of silly but I have no clue how to
Maybe this is a very silly question but I'm new using django. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.