title: What's the name of Google Analytics async design pattern and where is it used?
body: <p><a href="http://code.google.com/apis/analytics/docs/tracking/asyncUsageGuide.html" rel="noreferrer">Google Analytics async</a> code uses a very distinct design pattern for javascript code execution.</p>
  
  <p>The code depends on a library and it doesn't know if the library has loaded or not. If the library didn't load yet it just queues all the commands into an Array object. When the library loads it just creates the _gaq object and executes all commands in the sequence it was included. It then overwrites the push function so future commands are executed right away. </p>
  
  <p>The idea is to make the commands run very fast when they are queued. The code is only really evaluated later when the library is loaded.</p>
  
  <p>They also load the library with a parameters <code>async=true</code>. This causes almost no impact on the actual page loading time.</p>
  
  <p>The commands look just like the sync versions of it, but the first string is a function name and the next parameters are that function parameters. You can also push functions into this array and the functions will be executed in sequence as well with a null context. So if you need to do something synchronous with the library you can push a function to do this inside _gaq.</p>
  
  <p>I think this is a very clever solution but I have never seen it before. Does anyone know the name of this design pattern or where it's used besides the Google Analytics tracking code?</p>