possible to extract functions from a javascript file?
<p>Not sure if this is the right approach of if this even a "good" question, but I'm loading a javscript as part of a plugin style architecture and I have the following problem:</p>

<p>If a particular node has a reference to a plugin, I want to load that plugin per the url provided via the json description of that plugin.  the description will have something like the following (or a functional equivalent):</p>

<pre><code>{
  "pluginSrc" : "http://mysite.com/plugins/1204.js",
  "configData" :
    {
      "someData", "someValue",
      "someMoreData", "etc"
    }
}
</code></pre>

<p>When the javascript loads, I'll have an onload handler that will check to see if a function name exists on the window object and if so, create a new instance of that function and pass it the config data (more or less), this part works very well, with a few exceptions.</p>

<p>Sometimes I do not have a reference to the name of the function that I need to invoke and there is no way to get it from the json.  What would be ideal, is if I could tell which function was added to the window object on the script's onload callback and create an instance of that function.  Is this possible?  I only need to worry about modern browsers, particularly webkit. Apologies if the question isn't clear, I'd be happy to clarify, but producing a fiddle might be difficult as there's a lot of code to write to reach a minimal example.</p>

<p>What I'm thinking about so far is to create some kind of global variable in the loaded script file like</p>

<pre><code>function MediaAnalytics(){};
var LoadedClass = MediaAnalytics;
</code></pre>

<p>and just creating an instance of LoadedClass when the script is loaded, but this falls short of a panacea because I will not always be writing the plugin.</p>

<p>EDIT:  These scripts will most likely not be from the same domain.</p>
