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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:32:03+00:00 2026-06-17T10:32:03+00:00

I need to understand how image preloading works in browsers. Lets say I have

  • 0

I need to understand how image preloading works in browsers. Lets say I have this piece of code:

<script type="text/javascript" language="JavaScript">
    companyLogo = new Image();
    companyLogo.src = "/images/image1.jpg"
</script>

then somewhere below my page i have following.

<img src= "/images/image1.jpg" /> 

now as you can see, first i preloaded the image /images/image1.jpg And then i am using it within my image tag.

my website has product images, which are very HD and my entire page sometimes hangs while main image is loading. i dont mind size being big for my images, what I want to do is….keep loading the page with content & other elements and show the image as soon as its loaded (however do not HANG/PAUSE the page just because image is not loaded yet).

Now the above approach, what does it exactally do? does it preload the image in cache and waits and hangs the page? or it does exactally what i am trying to do?

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-06-17T10:32:04+00:00Added an answer on June 17, 2026 at 10:32 am

    While it sounds like you should be optimising your images instead, I;m happy to show you how I would do it.

    Don’t include the image src, hide it in data. (Use correct width and height so your page doesn’t jump when they eventually load.)

    <img src="1px.gif" data-src="http://the.real.src" class="justyouwait" style="width:10000000px; height:1000000px;" />
    

    Then on dom ready, i.e. when your page has loaded, load them

    $(function(){
        $('img.justyouwait').each(function(){
            $(this).attr('src', $(this).data('src'));
        });
    });
    

    Or add a bit of niceness

    $('img.justyouwait').each(function(){
        $(this).css({opacity:0}).load(function(){
            $(this).animate({opacity:1},1000); // fade them in
        }).attr('src', $(this).data('src'));
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Part 1) I have a bitmap/jpeg image. I need to convert this image into
I need to understand how this is possible, i.e. I would like to understand
I need to understand the working of this particular program, It seems to be
I don't know if this is a right question, but i need to understand
I edited this question after i found a solution... i need to understand why
This is trivial, probably silly, but I need to understand what state cout is
I need to understand what this means & how I go about resolving it
Possible Duplicate: Can someone Explain this jQuery code? I have posted this before, but
i have this image in the background: http://yoursdproperty.com/templates/pjo_joomlaforall/images/bgr.png of this page: http://yoursdproperty.com/index.php?option=com_jumi&fileid=8&Itemid=34 how do
Would appreciate any piece of advice on this. Need to dynamically renew the captcha

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.