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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:51:36+00:00 2026-06-09T15:51:36+00:00

I am fairly new to web development, so please excuse my ignorance. I’m working

  • 0

I am fairly new to web development, so please excuse my ignorance. I’m working on a page that generates color swatches which are just small sections of high resolution images. There are up to 70 of these swatches being generated at a single time. My problem is that I can’t get the images to fully show up on the first try, I have to call the function again to get the images to fully load. If I set up a function that makes my swatches visible upon loading (I’m using JQuery’s .load) it never triggers, I’m assuming because it never actually loads. Is there some way to force a full load of pages with a lot of content?

function showswatches(section, xmlHttpObj){
    for(i=0;i<xmlHttpObj.length;i++){
        if(xmlHttpObj[i].getElementsByTagName('section')[0].childNodes[0].nodeValue == section){
            $('#swatches').html();
            var colors = xmlHttpObj[i].getElementsByTagName('color');
            for(j=0;j<colors.length;j++){
                $('#swatches').append('<div class="swatch">');
                $('#swatches').append('<img src='+colors[j].childNodes[0].nodeValue+'>');
                $('#swatches').append('</div>');
            }
        }
    }
}
  • 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-09T15:51:37+00:00Added an answer on June 9, 2026 at 3:51 pm

    I can give you two options –


    First option –

    Add a .load() handler to each image and only display the image once it has fully loaded (in the mean time you could possible display a loader of sorts). If you give all your images the same class you cat attach the event to all of them at once. For example, if all of your <img> elements contain the preloadImg class, and you place a small loader element in your swatch container div, you could create a handler like this –

    $('img.preloadImg').on('load',function(){
      $(this).parent().find('loader').hide(); // hide loader
      $(this).show();  // images initially hidden
    });
    

    Second option –

    You could preload your swatches using JavaScript so that they start loading before your entire document is loaded and jQuery fires the document.ready callback. For this you can simply create an array of JavaScript Image() objects and give each one the appropriate src property.

    var imagePaths = ['swatch1.png','swatch2.png','swatch3.png'];
    var imageLoader = new Array();
    for(var i=0;i<imagePaths.length;i++){
      var img = new Image();
      img.src = imagePaths[i];
      imageLoader.push(img);
    }
    

    As soon as you create the Image() object and give it a src property, the image will start loading and this will possibly lessen your loading time becuase as I said before, the images will start loading as soon as JavaScript is available – before jQuery has loaded and even before your full HTML content is loaded.

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

Sidebar

Related Questions

I'm working on a Java EE (which I'm fairly new to) web application (JSF,
I'm fairly new to web development and I'd like to think I am getting
Hi I'm fairly new to web development and am stuck at the very first
So, I'm fairly new to web development, and I'm having a little trouble with
So I'm still fairly new to web page design and I've been messing around
I am fairly new to web development. So I apologize if this is a
I'm fairly new to Silverlight but experienced in web development, and I'm finding myself
I'm new to GWT and also fairly new to doing Java web development, using
I am new to Symfony+Doctrine, but fairly experienced with web application development in general
I am fairly new to web development & web services. I have been playing

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.