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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:35:27+00:00 2026-06-09T23:35:27+00:00

I know jQuery.load() , it’s fired when an <img> has completed downloading. I’d like

  • 0

I know jQuery.load(), it’s fired when an <img> has completed downloading.

I’d like to know what event is fired when the browser starts downloading the image. Normally at the first moment, the browser knows the size of the picture, and then it takes a while (depending on the picture size) for the picture to download.

I’d like to attach an event to know the picture size as soon as browser knows it, or as soon as the browser starts downloading it.

[EDIT]

Thank you for the idea from @jfriend00, now I use setInterval to check the size. BUT not the size of picture, some browser just not tell before finish downloading. So I check the size of container. Once picture size known by browser, it will adjust container size. Wala, done.

  • 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-09T23:35:28+00:00Added an answer on June 9, 2026 at 11:35 pm

    The browser does NOT provide a special event that will tell you the earliest possible time that it knows the size for an image (before it has finished downloading the image). All you can do is set up an appropriate load handler to know when the image has finished downloading and then its size is known.

    A brute force way that seems to work in some browsers for getting the height and width a little before the full image has loaded is to poll the loading image for the existence of .width and .height. In this jsFiddle in Chrome, it is sometimes available before the onload() event fires. I’ve not tested this in other browsers.


    If you go the route of an onload handler and your image tag with the .src specific is in the HTML of the page, the ONLY way to make sure you get notified when it is loaded is to put an inline image handler so the handler is installed from the very beginning:

    <img src="xxx.jpg" onload="handleLoad(this)">
    

    Trying to attach an event handler from your page javascript may be too late (after the image has finished loading). The browser does not provide intermediate event info (like when it knows the size, but hasn’t finished downloading the image).

    For dynamically created image objects (image objects you create in your javascript), you can attach a listener for the load event when you create the object.

    var img = new Image();
    img.onload = function() {
        // the image is now loaded here and height and width are known
    };
    img.src = "xxxx.jpg";
    

    Note: when doing this with dynamically created image objects, you MUST set the onload handler BEFORE you set the .src value. In some versions of IE, if the image is cached, the load event will fire immediately when the .src value is set so if you set .src first and then set the onload handler, you will miss the onload event if the image is in the browser cache.

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

Sidebar

Related Questions

I know that jQuery has .on() and .delegate() methods, but these require the event
I know that the jQuery .load() function has a problem: You can't retrieve pages
I would like to know, how to run something after the jQuery load? Does
I curious to know how the jQuery.load functionality affects page load speeds when reporting
I know jQuery does most when it comes to cross-browser issues. I just wanted
I know in jquery it is possible to call the javascript/jquery onload() / load()
Does anyone know how to check if jquery has been loaded (with javascript) then
Does anybody know of a way to make jQuery Mobile load only on pages
do you know a jQuery Autocomplete Plugin that has the following features. I have
I know this question has been asked, how to make a site like facebook/gmail

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.