From: Rick Waldron Date: Tue, 13 Sep 2011 20:45:59 +0000 (-0400) Subject: [#718] Removes script from head when script load is complete X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=156c8d9ffa47756a2895c51e196a35eb2a2262fb;p=popcorn-js.git [#718] Removes script from head when script load is complete --- diff --git a/popcorn.js b/popcorn.js index 8ce92f6..d653cfb 100644 --- a/popcorn.js +++ b/popcorn.js @@ -1637,27 +1637,21 @@ } - script.onload = script.onreadystatechange = function() { + script.onload = function() { - if ( !script.readyState || /loaded|complete/.test( script.readyState ) ) { - - // Handling remote script loading callbacks - if ( isScript ) { - - // getScript - success && success(); - } - - // Executing for JSONP requests - if ( isFired ) { - - // Garbage collect the callback - delete window[ callback ]; + // Handling remote script loading callbacks + if ( isScript ) { + // getScript + success && success(); + } - // Garbage collect the script resource - head.removeChild( script ); - } + // Executing for JSONP requests + if ( isFired ) { + // Garbage collect the callback + delete window[ callback ]; } + // Garbage collect the script resource + head.removeChild( script ); }; script.src = url; @@ -1794,7 +1788,7 @@ } } }; - + // alias for exec function Popcorn.p.cue = Popcorn.p.exec;