How to load page from SD card and still show live data from sensors?
Based upon this W3C example you can have w3-include-HTML.js file with the following contents:



function w3IncludeHTML() {
  var z, i, a, file, xhttp;
  z = document.getElementsByTagName("*");
  for (i = 0; i &lt; z.length; i++) {
    if (z[i].getAttribute("w3-include-html")) {
      a = z[i].cloneNode(false);
      file = z[i].getAttribute("w3-include-html");
      xhttp = new XMLHttpRequest();
      xhttp.onreadystatechange = function() {
        if (this.readyState == 4 &amp;&amp; this.status == 200) {
          a.removeAttribute("w3-include-html");
          a.innerHTML = this.responseText;
          z[i].parentNode.replaceChild(a, z[i]);
          w3IncludeHTML();
        }
      }      
      xhttp.open("GET", file, true);
      xhttp.send();
      return;
    }
  }


Now you can put this in your .html file:

&lt;div w3-include-html="generated_data.html"&gt;&lt;/div&gt;
&lt;script src="w3-include-HTML.js"&gt;&lt;/script&gt;


and then you can use something as:

server.on("/generated_data.html", live_data);


If you want to be able to use server.on() you must include &lt;ESP8266WebServer.h&gt; but you can serve the content the way you like. You can examine the ESP8266WebServer::on() method source code and adapt it according to your needs or you can just use that method as is.

Everything until now will result with calling the live_data() function and inserting it's response into the div which has the attribute w3-include-html="generated_data.html".

Now you only need to generate the live data inside the live_data() and to send the response:

void live_data() {
  String data_from_sensor;

  // read here the data from some sensor and store it in data_from_sensor
  String response = "&lt;h1&gt;Live data&lt;/h1&gt;&lt;p&gt;The data is: " + data_from_sensor + "some unit&lt;/p&gt;";
  server.send(200, "text/html", response);
}


And that's it. The live data generated inside live_data() will show where was the empty div with w3-include-html attribute.

Of course, you can have more divs with different w3-include-html attributes and belonging server.on() statements.

There are many ways, this is just an example so you can get an idea from where to start. This code will not update the live data on and on but now that you know the mechanism, you can modify the code to do whatever you like.