I am currently developing a Google Chrome extension and I want to express my gratitude to everyone here for tolerating my sometimes silly questions. The functionality of the extension is quite basic but it works smoothly. However, I am facing an issue where it runs too fast, causing the server to overload and block my IP address. Therefore, I believe it requires some sort of throttle mechanism.
My dilemma lies in whether it would be more effective to implement a timer or use setInterval for this purpose. Upon analyzing a specific page, the content script closes its window using self.close(). If I were to incorporate this into a setInterval function, it could delay the window closure and consequently slow down the entire process based on the length of the interval. This approach seems like a viable throttling solution.
The final line in the content script is simply:
self.close();
My assumption is that by making the following modification to the code, I can introduce a delay:
var t = setTimeout("self.close()", 2000);
Would this method be effective? Are there alternative techniques I should consider?