title: Electron - Why is there a big delay when loading the main window through localhost compared to an HTML file?
body: <p>When loading my main window by passing the HTML file directly through Electron, everything works as expected.</p>
  
  <p>Electron app:</p>
  
  <pre><code>mainWindow.loadURL(
    url.format({
      pathname: path.join(__dirname, "mainWindow.html"),
      protocol: "file:",
      slashes: true
    })
  );
  </code></pre>
  
  <hr>
  
  <p>But when using Express and accessing the main window through <code>localhost</code>, there is a big delay (white screen) at the first launch of the Electron app which lasts for about 30 seconds. </p>
  
  <p>However, The page is accessible through <code>localhost</code> in the browser as soon as the I run <code>electron .</code></p>
  
  <p>Express app:</p>
  
  <pre><code>app.get("/", (req, res) =&gt; {
    res.sendFile(path.join(__dirname, "mainWindow.html"));
  });
  app.listen(3000);
  </code></pre>
  
  <p>Electron app:</p>
  
  <pre><code>mainWindow.loadURL("http://localhost:3000");
  </code></pre>
  
  <p>I've tried this with multiple ports and they all give the same result.</p>