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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:44:58+00:00 2026-06-12T06:44:58+00:00

So there’s no issue with this code functionality itself. I have something like this:

  • 0

So there’s no issue with this code functionality itself. I have something like this:

<div>
    <div><img id="imageToChange" src="/path/image.png" /></div>
    <div id="textToChange">Text</div>
</div>

I have another part of my code, that changes the image src/text with jQuery.

function changeImage() {
    $('#imageToChange').prop('src', '/path/image2.png');
    $('#textToChange').html('New Text');
}

As you may expect, this works exactly as I expect it to. But with 1 quirk.

In all the main browsers (chrome/FF/IE). The image takes a long time to change.

So for example, when I call changeImage(), the text will change instantly, but the image may not change until 1-2 seconds later. (Not large images by any stretch, about ~6KB, and local)

I haven’t found anyone else really complaining about it, but what I’m wondering is if there’s any way to speed up the changing of the image src? Perhaps a better way to do it?

This is jquery 1.8.0 as well.

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-12T06:44:59+00:00Added an answer on June 12, 2026 at 6:44 am

    I have seen this behavior before. The delay is caused by the image not being cached and the subsequent load time. The only solutions I know of:

    1. Preload your images with JavaScript Image objects.
    2. Handle the load event on the image and update the text after the image as loaded. Note jQuery lists some issues to watch out for:

    Caveats of the load event when used with images

    A common challenge developers attempt to solve using the .load()
    shortcut is to execute a function when an image (or collection of
    images) have completely loaded. There are several known caveats with
    this that should be noted. These are:

    • It doesn’t work consistently nor reliably cross-browser
    • It doesn’t fire correctly in WebKit if the image src is set to the same src as before
    • It doesn’t correctly bubble up the DOM tree
    • Can cease to fire for images that already live in the browser’s cache

    http://api.jquery.com/load-event/

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

Sidebar

Related Questions

There are nice SO question and answers about this issue, but these options didn't
There is this strange situation I'm fighting on. I have 3 pages, les call
There have been multiple questions regarding this topic but I have never really settled
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
There are plenty of questions and answers to this like this question but I
There's a webpage with something annoying on it which I'd like to hide every
There is a <input type=checkbox name=option2 id=checkbox_3 value=3 /> I tried this code <script
There is something I miss with the notion of Synchronizing code in Android. Scenario
There have been a few variations of this question asked in the past few
There is a column that exists in 2 tables. In table 1, this column

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.