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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:01:55+00:00 2026-06-11T01:01:55+00:00

My overall problem is to lazy load images. I’ve gotten to the point where

  • 0

My overall problem is to lazy load images. I’ve gotten to the point where I’m loading the images only when they are on screen. I need to remove the images that are not on screen.

I thought

$(image).removeAttr("src")

would do it and it rightly removes src, but it does not clear the image from the screen, nor does it replace it with what is in alt.

How do I make it remove the image? Note, I do not want to remove the img tag (I need it for later), just clear the image from the screen.

Other code that may be relevant(although why I don’t know)-

updateCarImages:=>
    imagesOnScreen = $(@el).find(".carImageClass:onScreen")
    imagesOffScreen = _.without(cachedImagesOnScreen,imagesOnScreen)
    for image in imagesOnScreen
      imgSrc = $(image).attr("src")
      if (!imgSrc)
        id = $(image).data("tooltip-id")
        console.log(id)
        result = resultsStore.get(id+"")
        console.log(result)
        $(image).attr("src", result.get("carImageUrl"))
    console.log(imagesOffScreen)
    for image in imagesOffScreen
      $(image).removeAttr("src")
  • 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-11T01:01:56+00:00Added an answer on June 11, 2026 at 1:01 am

    If you are trying to clear memory (which as I see it would be the only reason to remove images that are not visible) you are up for a ride.

    There is no bullet proof way to force a browser to do that. The only way the browser will call the garbage collector is to reach a certain memory limit, and then hint the collector what it should take first.

    Moving nodes to a bin and empty it is considered a good way:

    var $trash = $('<div>').hide().appendTo('body');
    
    var waste = function(node) {
        $trash.append(node).html('');
    }
    

    You might get lucky with replacing the source with an empty GIF:

    $(image).attr('src','data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAA‌​LAAAAAABAAEAAAICRAEAOw%3D%3D');
    

    This will also keep the node in place and image width/height.

    But I highly doubt that any of this will result in any performance gain in your case, the best thing is to not stress the browser with too much data at all.

    iOS for iPad (especially version 4.x) is known for having a low memory limit and can easilly crash if you leave too many IMG nodes around.

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

Sidebar

Related Questions

i've a problem with my application that need to display a lot of images
Is loading only the needed classes directly a good way of reducing the overall
My overall use case: I have a Listing model that has many images .
My overall problem is that I have a large Excel file(Column A-S, 85000 rows)
I have an overall axisModel that is extended by subtypes of axes. The problem
My overall goal is isolate tags that contain a certain word in the text
Are there overall rules/guidelines for what makes a method thread-safe? I understand that there
I'm going to assume that the overall structure of my code as it currently
I'm making a program with the Pygame that changes the overall colours of inserted
Hi! The short question is: what can be the problem? The overall memory usage

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.