Tech Note: More Slowdowns Debugged

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

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.

Disprove this if you don't agree!

TwitterFacebook
LGF Pages
Recent Pages

researchok
'I Was Looking Forward to a Quiet Old Age': Instead, Etta Shiber, Helped Smuggle Stranded Allied Soldiers To Freedom
1 hour, 17 minutes ago
Views: 36 • Comments: 0
Tweets: 0 • Rating: 0

Daniel Ballard
Late Afternoon Light-Kalanchoe
8 hours, 58 minutes ago
Views: 88 • Comments: 0
Tweets: 0 • Rating: 3

MikeySDCA
Colin Powell Endorsed Same-Sex Marriage Once It Was Safe, More Evidence He's Hardly a Great Leader.
9 hours, 1 minute ago
Views: 109 • Comments: 1
Tweets: 0 • Rating: 0

Eclectic Infidel
City College of San Francisco Budget Update
9 hours, 50 minutes ago
Views: 106 • Comments: 0
Tweets: 0 • Rating: 0

Michael McBacon
Kansas governor signs 'Shariah bill' to ban Islamic law
14 hours, 21 minutes ago
Views: 214 • Comments: 6
Tweets: 0 • Rating: 5

Aigle
National Geographic Traveler Veers Off Track
1 day, 14 hours ago
Views: 438 • Comments: 7
Tweets: 0 • Rating: -5

MichaelJ
Apple TV Slated to Debut in December?
1 day, 15 hours ago
Views: 216 • Comments: 0
Tweets: 0 • Rating: 1

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

Haywood Jabloeme
The Harrassment of Patterico & Its Roots in Left-Wing Activism
1 day, 16 hours ago
Views: 510 • Comments: 2
Tweets: 0 • Rating: 4

Curt
Brian Banks: (Video) Falsely accused of rape speaks out
1 day, 19 hours ago
Views: 263 • Comments: 2
Tweets: 0 • Rating: 4

 Frank says:

If your children ever find out how lame you really are, they're gonna murder you in your sleep...