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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:37:42+00:00 2026-05-25T01:37:42+00:00

I have a list of objects MyObject and that looks like this: var Obj1

  • 0

I have a list of objects MyObject and that looks like this:

var Obj1 = {'ImgTop':'500px','ImgLeft':'200px','ImgSrc':'/image1.jpg'}
var Obj2 = {'ImgTop':'300px','ImgLeft':'100px','ImgSrc':'/image2.jpg'}

I load these objects into an array like this:

var AnimCycle = new Array(2);

AnimCycle[0] = Obj1;
AnimCycle[1] = Obj2;

In my code, there are actually 15 objects loaded in the array. I have function that gets called recursively and inside the function, I have this line:

$('#HomeImg').attr('src', AnimCycle[PanelID].ImgSrc); 

The problem is that the loading of the image happens when the line is triggered. How can I make the images preload?

Thanks for your suggestions.

  • 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-25T01:37:42+00:00Added an answer on May 25, 2026 at 1:37 am

    Here is a simple script which helps to load images before hand using javascript.

        $.each(data, function(index, item) {
            var tempImage = new Image();
            tempImage.src = item.url;
            preloadedImages.push(tempImage);
        }
    
    
    where data as an array of image data 
    data=
    {
       name:'NameofImage',
       url:'http://www.website.com/image1.jpg',
    }
    

    To display the images you can simply add the images to the DOM

     $("img").attr({
                    src: item.src
                }).appendTo("#target");
    

    I have a simple jsfiddle which demonstartes the script. It takes data from an ajax request and pre-loads the images. When the user does a mouseover the target it attaches the image to the DOM.

    Below is the screenshot showing the images are being loaded at the time the page gets loaded:

    Net tab of firefox showing the images being preloaded

    this reference link argues that images loaded in div which are hidden might not be pre-loaded in some of the browsers like Opera. I thought haven’t verified it.

    There might be other ways to load images using css if you do not want to use javascript

    Hope this helps

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

Sidebar

Related Questions

I have a collection of objects that look like this: List<MyObject> objects = new
I have an object in Javascript that looks like this function MyObject(){ this.name=; this.id=0;
Let's say I have an object MyObject that looks like this: public class MyObject
I have an object that looks like this: public MyObject { public int ObjectID
Hej, assuming I have a code that looks like this: List<User> userList = GetUserByName
Lately, I've been writing a lot of code that looks like this: List<MyObject> myList
I have an object that looks like this. List<List<string>> MyData; The inner List<string> can
I have List objects which are shown like this: www.mysite.com/lists/123 Where 123 is the
I have a SQL Server Stored Procedure that looks like this: CREATE PROCEDURE [dbo].[my_stored_procedure]
I have a Json file that looks like this: [ { field:val }, ....

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.