Side Channel

  • home
  • resources
Home › Blogs › helmi's blog

User login

What is OpenID?
  • Log in using OpenID
  • Cancel OpenID login
  • Create new account
  • Request new password

Navigation

  • Books
  • Feed aggregator

Recent blog posts

  • Ubuntu mirrors up and improved!
  • Google-jstemplate: Iterate object with unknown properties
  • nginx https proxypass for php apps
  • sugarcrm & memcache: Doing it Wrong
  • subversion and https in Ubuntu Karmic
  • Drupal: Views block delta converted to md5 hash
  • Ubuntu Server install requires PAE
  • Installing Drupal from command line
  • Drupal: Handling form field weight through CCK
  • minify javascript using Google Closure Compiler
more

angch's location

angch twitter

  • angch: Heading to Brunei. Business class for a change.
  • angch: tc qdisc htb activated on the mirror, and mirror reactivated. Hope nothing melts now.
  • angch: Hmmm, tbf doesn't work as advertised. htb does. #qos #linux
  • angch: @yoonkit me thinks #lucid is a much better tag than #lynx
  • angch: Great, you broke the dc's net and they disconnected us. Running to tpm from shah alam
more

asynchronous javascripts load

helmi's picture

helmi — Fri, 20/03/2009 - 11:53


if you want
better user experience
more revenue
reduced operating expenses
the strategy is clear
Even Faster Web Sites

- from slides Even Faster Web Sites

'Waterfall' chart

Much better version - Asynchronous load

I use drupal code patch as below to make asynchronous load, but this technique not working in IE.

user@portal:~/drupal$ svn diff common.inc 
Index: common.inc
===================================================================
--- common.inc  (revision 1)
+++ common.inc  (working copy)
@@ -1798,9 +1798,23 @@
         }
         break;
       default:
+        if (0) {
         foreach ($data as $path => $info) {
           $output .= '<script type="text/javascript"'. ($info['defer'] ? ' defer="defer"' : '') .' src="'. check_url(base_path() . $path) . ($info['cache'] ? '' : '?'. time()) ."\"></script>\n";
         }
+        } else {
+
+        $x = '<script type="text/javascript">var _d, _h=document.getElementsByTagName(\'head\')[0];';
+        foreach ($data as $path => $info) {
+          $x .=
+           "_d = document.createElement('script');\n".
+           '_d.src = "'.check_url(base_path() . $path) . ($info['cache'] ? '' : '?'. time()).'"; '."\n".
+           "_h.appendChild(_d);\n";
+        }
+        $x .= '</script>';
+        $output .= $x;
+        }
+
     }
   }

More techniques on asynchronous javascripts load on http://google-code-updates.blogspot.com/2009/03/steve-souders-lifes-too-...

  • javascript
  • performance
  • helmi's blog
  • Add new comment


Creative Commons License

  • home
  • resources

Standard Disclaimer.