title: DOMParser for large html
body: <p>I have a large amount of html clipboard data from Excel, about 250MB (though it contains a lot of formatting, so when actually pasting it in, the data is much, much smaller than that).</p>
  <p>Currently I am using the following <a href="https://developer.mozilla.org/en-US/docs/Web/API/DOMParser" rel="nofollow noreferrer"><code>DOMParser</code></a>, which is just one line of code and everything happens behind the scenes:</p>
  <pre><code>const doc3 = parser.parseFromString(htmlString, &quot;text/html&quot;);
  </code></pre>
  <p>However, it takes ~18s to parse this, and during this time the page is entirely blocking until it finishes -- <em>or, if offloaded to a webworker, an action that gives no progress and just 'waits' for 18s until something ends up happening -- which I would argue is almost the same as freezing even though yes the user can literally interact with the page</em>.</p>
  <p>Is there an alternative way to parse a large html/xml file? Perhaps using something that doesn't load everything at once and so can be responsive, or what might be a good solution for this? I suppose the following might be inline with it? But not really sure: <a href="https://github.com/isaacs/sax-js" rel="nofollow noreferrer">https://github.com/isaacs/sax-js</a>.</p>
  <hr />
  <p>Update: here is a sample Excel file: <a href="https://drive.google.com/file/d/1GIK7q_aU5tLuDNBVtlsDput8Oo1Ocz01/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/1GIK7q_aU5tLuDNBVtlsDput8Oo1Ocz01/view?usp=sharing</a>. You can download the file, open it in Excel, press Cmd-A (select-all), and Cmd-C (Copy), and it'll paste the data into your clipboard. For me copying it takes up 249MB for the text/html format in the clipboard.</p>
  <p>Yes, it is also available in teext/plain (which we use as a backup), but the point of grabbing it from the text/html is to <strong>capture the formatting</strong> (both data formatting, for example numberType=Percent, 3 decimals and stylistic, for example, background color=red). Please use that as a test for any sample code. Here is the actual <code>test/html</code> content (in asci) when it's in the clipboard here: <a href="https://drive.google.com/file/d/1ZUL2A4Rlk3KPqO4vSSEEGBWuGXj7j5Vh/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/1ZUL2A4Rlk3KPqO4vSSEEGBWuGXj7j5Vh/view?usp=sharing</a></p>