title: How to load fancybox only once in DotNetNuke (DNN) (JS is already included in theme and modules)
body: <p>I have a DotNetNuke website and I get a 'fancybox already initialized' error.</p>
  
  <p>I would like to know how I can check and only include the JavaScript file once when the page load? I know that the Script Manager will only add the JS file once, but what if the skin does not use the Script Manager?</p>
  
  <p>The theme includes the JavaScript file in the .ascx file in the following way:</p>
  
  <pre><code>&lt;dnn:DnnJsInclude runat="server"
  FilePath="js/jquery.fancybox3.min.js" PathNameAlias="SkinPath" /&gt;
  </code></pre>
  
  <p>My custom DNN module includes the same JS file using the Script Manager in the codebehind:</p>
  
  <pre><code>scriptInclude = new System.Web.UI.HtmlControls.HtmlGenericControl("script");
                  scriptInclude.Attributes["type"] = "text/javascript";
                  scriptInclude.Attributes["src"] = this.TemplateSourceDirectory + "/Scripts/jquery.fancybox.min.js";
                  scriptInclude.ID = ID + "_6";
  
                  Page.Header.Controls.Add(scriptInclude);
  </code></pre>
  
  <p>I need to add the Fancybox JS to all my modules because they can be installed on themes with Fancybox already included or not.</p>
  
  <p>I need the Fancybox code included in the theme if the module is not placed on a particular page.</p>
  
  <p>I have been thinking of creating a portal setting on all of my modules which will allows you to turn off the inclusion of the Fancybox JS file when it is already included in the theme.</p>
  
  <p>I have looked at other posts, but my question involves DNN Modules and the Theme itself.</p>
  
  <p>I did try to use this code in the theme from this post, but it seems not to work: <a href="https://stackoverflow.com/questions/6706145/how-to-check-if-fancybox-exists-on-page-already">how to check if fancybox exists on page already</a></p>
  
  <pre><code>if(typeof $.fancybox == 'function') {
       fancy box loaded;
  } else {
       fancy box not loaded;
  }
  </code></pre>