title: ELECTRON - Load local HTML file containing a script tag
body: <p>I'm relatively new to Node and Electron so I could be way off on this.</p>
  
  <p>Essentially what I'm trying to do is create a SPA that has a main navigation and the user can click on the links which will load local HTML files that contain a script tag. Currently I have a main page that uses fs to grab the html files and load it into a div successfully but none of the JS in that retrieved file works. I’m doing it this way because I need to interact with the UI and add dynamic elements </p>
  
  <p>this is what I have for code:</p>
  
  <p><em>mainWindow.html</em></p>
  
  <pre><code>&lt;script&gt;
      document.addEventListener('DOMContentLoaded', () =&gt; {
          fs.readFile(path.join(__dirname, 'fragments/main/welcome.html'), 'utf8', (err, data) =&gt; {
              document.getElementById('content').innerHTML = data;
          });
      });
  &lt;/script&gt;
  </code></pre>
  
  <p><em>welcome.html</em></p>
  
  <pre><code>&lt;section class="main-content-wide"&gt;
  &lt;h1&gt;Welcome to my app&lt;/h1&gt;
  &lt;p id="datetimeGreeting"&gt;&lt;/p&gt;
  &lt;p id="funFact"&gt;&lt;/p&gt;
  &lt;script&gt;
      console.log('Hello world');
  &lt;/script&gt;
  </code></pre>
  
  <p></p>
  
  <p>Thanks in advance.</p>
  
  <p><em>edit: if someone has a better way or a “best practice” way, I’d love to hear it.</em></p>