Tech Note: More Slowdowns Debugged
If you’ve been plagued with a message about an “unresponsive script” when you load LGF, I’m happy to report that the problem is fixed. Non-techies may now proceed to the open thread …
For the techlizards amongst us, here’s the explanation, because it may help someone diagnose a similar problem.
I didn’t know it until yesterday, but the jQuery Javascript library apparently builds an array of installed event handlers, and hooks into the window.unload event to remove those event handlers when the page is closed, to avoid memory leaks.
That’s why the “unresponsive script” message popped up when you navigated away from LGF, too. That was jQuery running through and unbinding all the event handlers.
The reason this suddenly started happening: in an effort to make our comment threads more unobtrusive, I recently changed the code to remove the onclick attributes of the ratings buttons and the reply/quote/report buttons, and installed event handlers on those elements via jQuery instead, at page load.
That’s where all the jQuery overhead came in, not only installing the handlers but building an array to uninstall them at page unload; I’ll bet the array part is what caused the ‘unresponsive’ error, because it would get very huge very quickly, especially on long comment threads. Probably gobbled a lot of RAM, too.
So I’ve switched back to the old-fashioned ‘onclick’ method for handling those events, which has apparently solved the problem.



