#346 bug
Mike Belshe

Error with double-included Prototype.js

Reported by Mike Belshe | September 16th, 2008 @ 09:03 PM | in 1.7

This isn't really a prototype.js problem. But there is a simple defensive coding change which can help. Proposed fix is included below.

The problem is that on WebKit browsers, NYT causes the CPU to spin with a setInterval timeout that never gets cleared. This is most noticeable on Chrome which has fast timers. The cause is that NYT currently includes prototype.js twice via this URL: http://www.nytimes.com/2008/09/1... This page includes prototype.js and also include graphics8.nytimes.com/js/app/linkedin/linkedinheadlines.js, which duplicate includes prototype.js.

Because of this, two setInterval timers get set, and when the page loads, only one of the intervals gets cleared.

The one-liner fix is to change this code: function fireContentLoadedEvent() {

if (document.loaded) return;
if (timer) window.clearInterval(timer);
document.fire("dom:loaded");
document.loaded = true;

}

to this: function fireContentLoadedEvent() {

if (timer) window.clearInterval(timer);  // Be sure the timer gets cleared
if (document.loaded) return;
document.fire("dom:loaded");
document.loaded = true;

}

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins

Attachments

Pages