#718 ✓ staged
cadecairos

Popcorn.getScript can call callback before an onload has fired

Reported by cadecairos | September 13th, 2011 @ 04:11 PM | in 0.9 (closed)

If getScript is called in succession to load the same script (which is possible in several plugins which load scripts in _setup), the second call to getScript sees the script tag in head and bails early, calling the callback. This is not good, because the script previously appended to the head hasn't fired onload and isn't actually loaded.

In the reduced test case I wrote, the second callback to getScript returns first, and the global function in testFunction.js file I'm getting hasn't loaded yet.

The code behind this issue is on lines 1582-1595 in popcorn.js:

//  If this is a script request, ensure that we do not call something that has already been loaded
if ( isScript ) {

var scripts = document.querySelectorAll( "script[src=\"" + url + "\"]" );

  //  If there are scripts with this url loaded, early return
  if ( scripts.length ) {

    //  Execute success callback and pass "exists" flag
    success && success( true );

    return;
  }
}

We need a way to ensure the callbacks to redundant getScripts are handled so that they don't return before the script is ready.

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 »

Popcorn.js is an HTML5 video framework that lets you bring elements of the web into your videos.

Popcorn.js is a project of Web Made Movies, Mozilla's Open Video Lab.

Shared Ticket Bins

Referenced by

Pages