Hashim1's Profile User Rating: -----

Reputation: 1 Apprentice
Active Posts:
26 (0.02 per day)
13-June 12
Profile Views:
Last Active:
User is offline Oct 13 2015 01:09 PM

Previous Fields

Dream Kudos:
Icon   Hashim1 has not set their status

Posts I've Made

  1. In Topic: Why does my script slow down after so long?

    Posted 12 Oct 2015

    View PostArtificialSoldier, on 12 October 2015 - 10:16 AM, said:

    That's an indication that the update process might remove or replace that element, which would break the reference. You can use console.log to check that though, get the element and send it to the console, then call the click method, then send the element to the console again and see if it's still there. After the first click you can also get the element again and compare it with the first one, see if they're the same.

    So something like this:

    var find_older_element = document.getElementById('see_older').getElementsByClassName('content')[0];
    setInterval(function() {
    }, 250);

    Inputting that into the console gives me this as output:

    2015-10-12 18:31:53.838 VM73:3 <div class=​"content">​​</div>​
    2015-10-12 18:31:53.840 VM73:7 <div class=​"content">​​</div>​

    The first two lines correspond to the console.log lines in the code, presumably indicating the element exists both before and after the click event. Not sure what the extra
    is about.
  2. In Topic: Why does my script slow down after so long?

    Posted 11 Oct 2015

    Fair enough, although I'd argue that even quoting the quote directly above you - albeit not in huge chunks - is easier to follow and streamlines the experience of reading through a thread more than re-reading the above post and then the one below it.

    View Postastonecipher, on 11 October 2015 - 01:41 PM, said:

    This seems like an unusually low number to use,

    }, 250);

    I'm aware of how long it is - the reason is because I need this task to be done as fast as possible. I've decreased and increased that, it doesn't really make any difference apart from slightly increasing or decreasing the overall time it takes to load all the messages, and it definitely isn't causing the current problem. Loading 100,000 messages 3 at a time even every 500 ms takes 8+ hours, hence the need for a low time. I've since upped that time to 450 ms just to make it a bit smoother and decrease the amount of lag that comes into play after the script has been running for a few hours.
  3. In Topic: Why does my script slow down after so long?

    Posted 11 Oct 2015

    Isn't the whole purpose of quoting someone to notify them? Does the quick reply still do that? If not, I'm not entirely sure why my post was edited for making use of a forum function, least of all one that has an advantage over other equivalent ones.
  4. In Topic: Why does my script slow down after so long?

    Posted 11 Oct 2015

    That was a brilliant explanation, thanks a lot.

    I've decided to do it the simpler way, with the reference called once outside of the function:

    var find_older_element = document.getElementById('see_older').getElementsByClassName('content')[0];
    setInterval(function() {
    }, 250);

    For some reason, however, it's not behaving as it should. Running this piece of code in Chrome's JS console initiates the first click, and then doesn't do anything, although it does appear to be constantly trying to load something to no success (the circular loading animation that shows in the tab never goes beyond a quarter before starting again, as if it the browser's trying to load several things one after the other in quick succession).

    By contrast, the original version:

    setInterval(function() {
    }, 150);

    ...works just as perfectly as before, so it doesn't seem to be the new code that's at fault rather than anything to do with Facebook or my internet connection. Any idea what might be causing this?
  5. In Topic: Why does my script slow down after so long?

    Posted 8 Oct 2015

    View PostArtificialSoldier, on 08 October 2015 - 02:36 PM, said:

    You don't really have any control over that. You're telling it to continue to add new elements to the document tree, that's where all the memory is.

    That's a shame.


    If you use document.getElementById or document.getElementsByClassName you are asking the browser to look through the DOM every time that function runs. As the size of the DOM continues to grow, it's going to get slower and slower to search through it. If you only run those functions once and save the reference to that element, then you can just call the click method each time through your function instead of needing to search through the DOM each time.

    Hence this solution:

    var see_older_element = document.getElementById('see_older').childNodes[0].childNodes[1].childNodes[0];
    	setInterval(function () 
    }, 150);

    There's something I'm not understanding with that, though. Even if those references to the DOM aren't in the function, aren't they still part of the code, and therefore going to be run each time anyway? Do DOM references inside of functions take more resources than those outside of them?

    One more thing - this is my first exposure to child nodes in Javascript, and even after research earlier on, I'm a bit confused about how they works. I've gathered that a child node is basically a DOM element, how the DOM... interfaces with elements on a webpage, so I'm guessing they're not dynamic. If this is true, how do I go about finding the child node for the particular button that I want to click, so I can set the script up as you suggested earlier on?

    Once again, thanks for the help, it's much appreciated. I'm sorry if these are beginner questions, I'm not as adept in Javascript as I'd like to be just yet. :rolleyes2:

My Information

Member Title:
New D.I.C Head
Age Unknown
Birthday Unknown

Contact Information

Click here to e-mail me


Hashim1 hasn't added any friends yet.


Hashim1 has no profile comments yet. Why not say hello?