mixmark-io / turndown

🛏 An HTML to Markdown converter written in JavaScript
https://mixmark-io.github.io/turndown
MIT License
8.66k stars 873 forks source link

Switch from jsdom to domino for perf #346

Closed Sebmaster closed 4 years ago

Sebmaster commented 4 years ago

This significantly speeds up parsing since the DOM implementation in domino is quite a bit leaner than jsdom. In my local tests the test suite for turndown goes from 2.5s -> 1.5s. I assume the gain in large docs - especially those containing CSS (which jsdom does interpret) - are even greater.

Additionally, this does remove quite a large dependency (+ sub deps) in node environments.

While this switch does change the HTML parser used (which used to lead to different parsing results in ye olden times), it seems that domino does include html5lib tests which are the same ones parse5 uses, so that gives some confidence that the HTML5 parsing spec is implemented properly in both and won't change results.

Sebmaster commented 4 years ago

Oh I see this was already opened in #328.