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 8704577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:08:30+00:00 2026-06-13T03:08:30+00:00

Given a number of images (animation frames) I would like to prefetch them and

  • 0

Given a number of images (animation frames) I would like to prefetch them and then show them on a webpage as needed.

I have tried several ways of prefetching, including a nifty plugin, but here’s a dead simple method:

<div class="animation-container"></div>

<div class="holding-container" style="display:none"></div>

<script>
$('.holding-container').append('<img src="Image1.png" />');
$('.holding-container').append('<img src="Image2.png" />');
</script>

In the Network tab of Firebug or developer tools, I see these calls result in queries to the server, and the images are fetched successfully.

Now, I want to actually use the images. Here’s some very simplified code:

$('.animation-container').prepend('<img src="Image1.png"/>');

This is where things go off the rails. The network tabs show the browsers query the server again (receiving 304 NOT MODIFIED). This results in about a 200ms delay before the image is shown. Why does this happen and what can I do about it?

  • 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-06-13T03:08:33+00:00Added an answer on June 13, 2026 at 3:08 am

    You are creating a new DOM object instead of re-using the one that was pre-fetched.

    Add an id to each image to uniquely identify it –

    <div class="animation-container"></div>
    <div class="holding-container" style="display:none"></div>
    <script>
        $('.holding-container').append('<img src="Image1.png" id="img1" />');
        $('.holding-container').append('<img src="Image2.png" id="img2" />');
    </script>
    

    And then to grab the element using a selector, detach() it (like remove() but keeps the info, you can omit this if you you want to keep it in your holding container), and prependTo() it to your container:

    $('.holding-container #img1').detach().prependTo('.animation-container');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a fixed number of images, given by my client (not coming from
I have some bitmaps and I would like to save them to a single
Given a known number of images with the same width to height ratio and
I'm writing a code to identify the subfix for a given number. I have
I have a requirement for the generation of a given number N of vectors
I have data that always looks something like this: alt text http://michaelfogleman.com/static/images/chart.png I need
A Ruby on Rails app will have access to a number of images and
I have a number of images in my db and they all correspond to
I have a game with a number of animated monsters. The animation is made
I would like to represent dynamic images in an email. For example with the

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.