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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:21:15+00:00 2026-06-04T15:21:15+00:00

I have inserted this script in a webpage with 50 small images ( from

  • 0

I have inserted this script in a webpage with 50 small images ( from 16x16px to 50x50px ):

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('img').css('opacity', '0.0').load(function(){
    $(this).animate({'opacity': '1.0'});
});         
});
</script>

The problem is that not every images are loaded and some doesn’t appears.

Why ?

  • 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-04T15:21:17+00:00Added an answer on June 4, 2026 at 3:21 pm

    There are chances that some images are being loaded from cache. And if the image is loaded from cach then load event would fire before dom ready event. One way to do this would be

    $('img').css('opacity', '0.0').one('load',function(){
        $(this).animate({'opacity': '1.0'});
    }).each(function() {
       if(this.complete) $(this).load();
    });
    

    This will loop through the images and check if they has been loaded from cache, if so then it will fire load event for those images.

    And I am using $.one to run the event handler only one time as we dont need it to be executed more than one time.

    UPDATE:

    if(this.complete) will check if the image is already loaded(in case of cached they are) and if they are then it will fire load event for those immediately.

    And which are not loaded from cache, browser will fire load event for them after they are loaded.

    So the above code will cover all images, cached or not.

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

Sidebar

Related Questions

I have inserted the following line into my Joomla template: <jdoc:include type=component /> This
I'm trying to select an element from my webpage... I have inserted a control
I have this little jQuery plugin: <!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http://www.w3.org/TR/html4/loose.dtd>
Hope to get a little help from you guys. Im using this script when
I have put together some code from various sources but javascript is somewhat unknown
Well basically I have this script that takes a long time to execute and
I have a javascript widget that can be inserted on an a plain-old html
I have a script that is being inserted dynamically via another script. The code
I have successful inserted datepicker into my webpage and it works smoothly now. What
I have a <script> where it adds to the <head> another script. This new

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.