title: JavaScript: getting the raw bytes of the page itself
body: <p>I'm trying to get the <strong>raw bytes</strong> [1] of a webpage itself as sent by the server.</p>
  
  <p>Is JavaScript even able to do this?</p>
  
  <p>Attempt 1:</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;script&gt;
  onload = ()=&gt;{
    console.log(document.body.innerHTML); 
  };
  &lt;/script&gt;
  &lt;body&gt; 
  
  pasting raw bytes here, eg:
  
  asdfg &lt;a&gt;  hi  &lt;/b&gt; xyz
  
  boundary=gc0p4Jq0M
  
  raw bytes image 1 here
  
  --gc0p4Jq0M
  
  boundary=ggUjM
  
  raw bytes css page 1 here
  
  --ggUjM
  
  boundary=yyJAkM
  
  raw bytes js page 1 here
  
  --yyJAkM
  
  a couple more resources here
  </code></pre>
  
  <p>..doesn't work. [It shows the parsed dom.]</p>
  
  <hr>
  
  <p>1: meaning no or almost no escaping, to keep bandwidth at a minimum.</p>