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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:21:23+00:00 2026-06-05T05:21:23+00:00

I’m having a problem with a javascript that randomly creates background divs on a

  • 0

I’m having a problem with a javascript that randomly creates background divs on a page (to create these floating circles on the background of my site). The script runs on an interval:

var floatInterval = window.setInterval(createFloaters, 10000);
function createFloaters()
            {
                lastHeight = 0;
                pageOffset = $('#logo').offset();
                for(j = 0; j<10; j++)
                {
                    randomSize = j * Math.random()*20;
                    randomTop = Math.random()*randomSize + lastHeight + Math.random()*10 + 10;
                    plusOrMinus = [-1,1][Math.random()*2|0];
                    randomColorNum = Math.floor(Math.random()*colArr.length);
                    randomColor = colArr[randomColorNum];
                    randomLeft = Math.random()*990 + pageOffset.left;
                    randomOpacity = Math.random()*.5;

                    $('#floatContainer').append('<div class="circle d' + j + '" style="width:' + randomSize + 'px; height:' + randomSize + 'px; position: absolute; top:' + eval((randomTop - Math.random()*500)*plusOrMinus) + 'px; left:' + eval((randomLeft + Math.random()*200)*plusOrMinus) + 'px; border-radius:' + randomSize + 'px; background:' + randomColor + '"></div>');
                    lastHeight += randomSize;
                    $('.d' + j).delay(Math.random()*500).animate({top: randomTop, left: randomLeft, opacity: randomOpacity}, Math.random()*5000 + 5000).fadeOut().queue(function(){

                    $(this).remove();


                    });
                }

                console.log('FLOAT LENGTH: ' + $('#floatContainer div.circle').length);
            }

Once a floating circle is created, it animates and then is removed. It appears that the divs aren’t being completely removed.

When I traced out the number of divs being created while focused on the tab I get something normal.

Number of Divs: 13
Number of Divs: 21
Number of Divs: 13
Number of Divs: 21
Number of Divs: 13
Number of Divs: 21

Then I switch tabs, sit there for a few minutes, return to the original tab and this is what I see:

Number of Divs: 187
Number of Divs: 197
Number of Divs: 207
Number of Divs: 13
Number of Divs: 21
Number of Divs: 13
Number of Divs: 21
Number of Divs: 13
Number of Divs: 21

What can I do to correct this issue? How do you delete the dynamically created divs permanently from memory? I checked the activity monitor and the page continues to hog memory the longer it runs.

  • 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-05T05:21:26+00:00Added an answer on June 5, 2026 at 5:21 am

    You are using queue wrong. Just add a callback to fadeOut.

    .fadeOut(function(){$(this).remove();});
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Basically, what I'm trying to create is a page of div tags, each has
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the

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.