Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #519.
Extraction is 11% faster on linkedom and 15% faster on JSDOM, on top of #519.
removeHiddenElementsranquerySelector('math, [data-mathml], .katex-mathml')on every element before checking whether it was hidden.findMainContentranFOOTNOTE_INLINE_REFERENCESandFOOTNOTE_LIST_SELECTORSfor every candidate and scored duplicates again.scoreAndRemovecalledclosestandquerySelectorfor every block.src/removals/hidden.tswalks the tree, checks hiddenness first, and looks for math only in hidden elements.src/defuddle.tscollects footnote ancestors once and caches candidate scores.src/removals/scoring.tsscores blocks in one walk and shares text, link and heading counts between its content check and its score.Medians on top of #519: linkedom 1,168 → 1,038 ms, JSDOM 3,959 → 3,349 ms, both outside the spread. Alone on 0.19.11, all three were within the noise. It adds 0.8 KB gzipped to both bundles, and the core budget goes from 99 to 100 KB. +368 / −247 lines.
With all five PRs, extraction goes from 2,012 to 981 ms on linkedom and from 6,760 to 3,322 ms on JSDOM, 51% faster on both, for 5.4 KB gzipped.
Output is byte-identical to #519 for all 250 fixtures, at each fixture's own URL and at
https://example.com/page, with no options,separateMarkdownandmarkdown, under linkedom and JSDOM (1,500 runs each).tsc --noEmit,lint:unused,lint:innerhtml,npm run sizeand both Vitest suites pass. Timing alternates fresh processes of each branch over 0.19.11's 248 fixtures, 9 pairs on linkedom and 7 on JSDOM. I haven't run it in a browser, happy-dom or the Cloudflare Worker, and the output check doesn't cover debug mode.