title: Embedding all the external resources of an HTML page into a single file using javascript in the browser
body: <p>As you all know, external resources, like images, can be embedded into the html file using base64 encoding:</p>
  
  <pre><code>&lt;img src="data:image/png;base64,iVBORw0KGgoAAAANS..." /&gt;
  </code></pre>
  
  <p>I'm looking for <strong>a pure browser-based javascript</strong> way to traverse an html page and embed all the external resources into the file so when I say <code>$("html").html()</code>, it returns all the page's contents. Even including its external resources.</p>
  
  <p>Just so it makes sense, I'm trying to download web pages into single files using a headless browser on my server.</p>