title: Include JavaScript files from a control if the files have not been included before
body: <p>I have written a control requires certain JavaScript files to run, like<br>
  jquery-1.5.1.min.js<br>
  jquery.colorbox.js<br>
  and another custom file, lets call it gallery.js</p>
  
  <p>I'm thinking about how I can make the control more reusable on different content pages, without the need to load the scripts on pagelevel with the ScriptManagerProxy, meaning that I don't need to do this on every content page:</p>
  
  <pre><code>&lt;asp:ScriptManagerProxy ID="proxy1" runat="server"&gt;
     &lt;Scripts&gt;
       &lt;asp:ScriptReference Path="~/scripts/jquery-1.5.1.min.js" /&gt;
       &lt;asp:ScriptReference Path="~/scripts/jquery.colorbox.js" /&gt;
       &lt;asp:ScriptReference Path="~/scripts/gallery.js" /&gt;
     &lt;/Scripts&gt;
  &lt;/asp:ScriptManagerProxy&gt;
  </code></pre>
  
  <p>That implementation has one disadvantage. If I want to use the control on another page, I'd have to think about the scripts being required. I would rather use an implementation where the control itself loads the necessary JavaScript files, without loading certain scripts more then once.
  Let's assume I use my control three times on the same page, so I don't want to end up loading all the JavaScript files three times. What can I do?</p>
  
  <p>I'm looking for a solution like this:</p>
  
  <pre><code>if(Page.Scripts["path to javascript file"] == null)
  {
   Page.Scripts.InsertJavaScript("path to javascript file");
  }
  </code></pre>
  
  <p>How can I proceed in this situation? (I don't want to load the scripts on a pagelevel or in a masterpage to produce unnecessary overhead)</p>