]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#718] Removes script from head when script load is complete
authorRick Waldron <waldron.rick@gmail.com>
Tue, 13 Sep 2011 20:45:59 +0000 (16:45 -0400)
committerRick Waldron <waldron.rick@gmail.com>
Tue, 13 Sep 2011 20:45:59 +0000 (16:45 -0400)
popcorn.js

index 8ce92f606339160840f5c5a4080566c7bd57e9e8..d653cfb071102683a609e06aa8e2e5063593ee32 100644 (file)
 
     }
 
-    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;
       }
     }
   };
-  
+
   // alias for exec function
   Popcorn.p.cue = Popcorn.p.exec;