Tech Note: More Slowdowns Debugged

Charles Johnsonfollow me on twitter
Tue Feb 26, 2008 at 2:21 pm PST • Views: 204

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.

Advertisement

206 comments

^ back to top ^

Name:

Pass:

Register Forgot Your Password? Re-send Confirmation (To log in, cookies must be enabled in your browser!)

Turn off ads by subscribing!
For about 33 cents a day, our subscription option turns off all advertisements at LGF!
Read more...


► LGF Headlines

  • Loading...

► Tweeted Articles

  • Loading...

► Tweeted Pages

  • Loading...

► Top 10 Comments

  • Loading...

► Bottom Comments

  • Loading...

► Recent Comments

  • Loading...

► Tools/Info

► Tag Cloud

► Contact

You must have Javascript enabled to use the contact form.
Your email:

Subject:

Message:


Messages may be published in our weblog, unless you request otherwise.
Tech Note:
Using the Contact Form

More Partners

Compare Electricity Prices in your area. Texas Electricity is deregulated; you have the right to choose Texas Electric Rates from among many Texas Electric Companies.

Now with polemical tangents.

TwitterFacebook
LGF Pages
Recent Pages

MikeySDCA
How an 11-Year-Old Survived the Houla Massacre - the Atlantic Wire
1 hour, 54 minutes ago
Views: 49 • Comments: 0
Tweets: 0 • Rating: 1

Randall Gross
Fairbanks Militia Leader Compared to Cult Leaders
2 hours, 38 minutes ago
Views: 78 • Comments: 0
Tweets: 0 • Rating: 1

researchok
Lost Classics: An Address Delivered in 2009 to Graduates in Classics at UC Berkeley
15 hours, 49 minutes ago
Views: 169 • Comments: 0
Tweets: 0 • Rating: 0

Haywood Jabloeme
SWATting the Ericksons
18 hours, 53 minutes ago
Views: 209 • Comments: 2
Tweets: 0 • Rating: -4

Mostly sane, most of the time.
So wake up and notice already
19 hours, 1 minute ago
Views: 127 • Comments: 0
Tweets: 0 • Rating: 1

Daniel Ballard
Late Afternoon Light-Kalanchoe
1 day, 23 hours ago
Views: 215 • Comments: 0
Tweets: 0 • Rating: 5

Eclectic Infidel
City College of San Francisco Budget Update
2 days ago
Views: 254 • Comments: 0
Tweets: 0 • Rating: 1

Aigle
National Geographic Traveler Veers Off Track
3 days, 5 hours ago
Views: 898 • Comments: 29
Tweets: 26 • Rating: -6

MichaelJ
Apple TV Slated to Debut in December?
3 days, 6 hours ago
Views: 315 • Comments: 0
Tweets: 0 • Rating: 1

Ascher
Israeli Who Saved Turk on Everest: You Never Abandon a Friend - Israel News, Ynetnews
3 days, 7 hours ago
Views: 389 • Comments: 1
Tweets: 0 • Rating: 4

 Frank says:

Sometimes you got to get sick before you can feel better.