]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#556] Made some performance changes
authorDavid Seifried <david.c.seifried@gmail.com>
Wed, 22 Jun 2011 15:44:39 +0000 (11:44 -0400)
committerDavid Seifried <david.c.seifried@gmail.com>
Wed, 22 Jun 2011 15:44:39 +0000 (11:44 -0400)
plugins/googlefeed/popcorn.googlefeed.js

index a52d31cf9d560c3d6e9ba48887e4333a999fe926..df44a77bc7b16fda1180d393016e7bfb3fef4a60 100755 (executable)
@@ -9,12 +9,13 @@
         k = 0,
         links = document.getElementsByTagName( "link" ),
         len = links.length,
-        head = document.getElementsByTagName( "head" )[ 0 ],
-        css = document.createElement( "link" );
+        head = document.head || document.getElementsByTagName( "head" )[ 0 ],
+        css = document.createElement( "link" ),
+        resource = "http://www.google.com/uds/solutions/dynamicfeed/gfdynamicfeedcontrol.";
 
-    if ( typeof GFdynamicFeedControl === "undefined" ) {
+    if ( !window.GFdynamicFeedControl ) {
 
-      Popcorn.getScript( "http://www.google.com/uds/solutions/dynamicfeed/gfdynamicfeedcontrol.js", function() {
+      Popcorn.getScript( resource + "js", function() {
         scriptLoaded = true;
       }); 
 
@@ -24,7 +25,7 @@
 
     //  Checking if the css file is already included
     for ( ; k < len; k++ ){
-      if ( links[ k ].href === "http://www.google.com/uds/solutions/dynamicfeed/gfdynamicfeedcontrol.css" ) {
+      if ( links[ k ].href === resource + "css" ) {
         dontLoad = true;
       }
     }
     if ( !dontLoad ) {
       css.type = "text/css";
       css.rel = "stylesheet";
-      css.href =  "http://www.google.com/uds/solutions/dynamicfeed/gfdynamicfeedcontrol.css";
+      css.href =  resource + "css";
       head.insertBefore( css, head.firstChild );
     }
   };
 
-  if ( typeof google === "undefined" ) {
+  if ( !window.google ) {
 
     Popcorn.getScript( "http://www.google.com/jsapi", function() {