title: Included script in HTML file does not run in Google Apps Script HTMLService
body: <p>I have a Templated HTML file I am loading and can load other HTML using the functions as shown in the code below. I am trying to get included functions to run in the script tags. This is an HTMLService in a Google Sheet script.</p>
  
  
  
  <p>In <strong>Code.gs</strong> I have</p>
  
  <pre class="lang-js prettyprint-override"><code>function doGet() {
    var template = HtmlService.createTemplateFromFile("template")
                              .evaluate() 
                              .setTitle('My Title')
                              .setHeight(700)
                              .setWidth(1000)
                              .setSandboxMode(HtmlService.SandboxMode.NATIVE);
  
    return template
  
  //  SpreadsheetApp.getActive().show(template);
  };
  
  function include(filename) {
    return HtmlService.createHtmlOutputFromFile(filename).getContent();
  };
  
  function includeRaw(filename) {
      return HtmlService.createTemplateFromFile(filename).getRawContent();
  }
  </code></pre>
  
  <p>And in my <strong>template.html</strong> I have</p>
  
  <pre class="lang-js prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
       &lt;base target="_top"&gt;
        &lt;?!= include('mystylesheet'); ?&gt;
       &lt;?!= includeRaw('Billets_JS'); ?&gt;
  
     &lt;/head&gt;
     &lt;body&gt; ...(more body)
        &lt;select id="optionListYear" onchange="setFormList()"&gt;
           &lt;option&gt;Option 1&lt;/option&gt;    
           &lt;option&gt;Option 2&lt;/option&gt;    
        &lt;/select&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  
  &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"&gt;
  &lt;/script&gt;
  &lt;script&gt;
    function setFormList() {
      alert("In setFormList");
      MyNEwFunction();
    }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>I have also tried the straight include() function for the JavaScript file</p>
  
  <p><strong>Billets_JS</strong> has this:</p>
  
  <pre class="lang-js prettyprint-override"><code>&lt;script&gt;
      alert("Script included!");
  
  // This code in this function runs when the page is loaded IF in the initial html file.
  $(function() {
  
    alert("In the intial function");
  });
  
  function MyNewFunction() {
    alert("In My New Function");
  
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>I can get the HTML file with only script ("Billets_JS") to load. If I have an alert(); line outside of any functions in this included file, such as the one shown, the line runs. So I get an Alert box stating "Script included!" But not the one for "In the initial function."</p>
  
  <p>I cannot seem to call MyNewFunction() this way, though. I have used both Include functions found in Code.gs</p>
  
  <p>Is there any way to load script that will run without putting it all in the initally loaded file? Simply moving the functions to the intially loaded file works, but I would rather segregate them.</p>