Tech Note: More Slowdowns Debugged

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

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? Account Settings 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

► LGF Hits

► Resources

► Never Forget

► Statistics

► 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.

Democracy, whisky, sexy!

TwitterFacebook
LGF Pages
Recent Pages

Bob Dillon
Radiation Generates Cancer Stem Cells From Less Aggressive Breast Cancer Cells
58 minutes ago
Views: 26 • Comments: 0
Tweets: 0 • Rating: 0

Bob Dillon
Mossad Bolsters Activity in Tunisia
1 hour, 18 minutes ago
Views: 40 • Comments: 0
Tweets: 0 • Rating: 0

Bob Dillon
CA Prison Officers Spent More Than $1 Million on Political Advice
1 hour, 28 minutes ago
Views: 28 • Comments: 0
Tweets: 0 • Rating: 0

Bob Dillon
China Withdraws Support to Assad
1 hour, 35 minutes ago
Views: 46 • Comments: 0
Tweets: 0 • Rating: 0

Bob Dillon
'Assad Using Chemical Warfare in Homs Attack
1 hour, 38 minutes ago
Views: 37 • Comments: 0
Tweets: 0 • Rating: 0

Bob Dillon
Weapons: Neutering Ammonium Nitrate
1 hour, 49 minutes ago
Views: 40 • Comments: 0
Tweets: 0 • Rating: 0

Randall Gross
Stabenow Up 14 on Hoekstra as Ad Backfires - Public Policy Polling
2 hours, 25 minutes ago
Views: 87 • Comments: 0
Tweets: 0 • Rating: 0

Randall Gross
Youth for Western Civilization Takes 'Patriot' Plunge
2 hours, 35 minutes ago
Views: 82 • Comments: 0
Tweets: 0 • Rating: 0

Randall Gross
'Sovereign Citizen' Sues Government Over Grammar
2 hours, 39 minutes ago
Views: 88 • Comments: 0
Tweets: 0 • Rating: 0

Randall Gross
Apple 'Determined' to Improve Conditions at Plants in China
2 hours, 59 minutes ago
Views: 65 • Comments: 0
Tweets: 0 • Rating: 2

 Frank says:

A lot of things wrong with society today are directly attributable to the fact that the people who make the laws are sexually maladjusted. -- from "I Seem To Be a Verb" by R. Buckminster Fuller, 1970.