neaumusic / selection-highlighter

browser highlighter for code analysis
BSD 3-Clause "New" or "Revised" License
82 stars 15 forks source link

Add an option to delay highlightings #23

Closed openaphid closed 1 year ago

openaphid commented 4 years ago

For large documents like editing a source file on Github, the page would freeze when trying to select and delete some texts. It would be helpful to have an option to specify a delay to highlight when selection is changed.

neaumusic commented 4 years ago

good idea, I will probably work on this, thanks

neaumusic commented 4 years ago

@openaphid I found a bug while comparing query method against xpath and discovered the performance hit was from normalize() of every text element on the page, regardless of whether anything was spliced. if you clone or download this repo, you can Load Unpacked 2.26 and it should be way more performant, something like 2000x faster

neaumusic commented 4 years ago

I might still add the delay idea, but see https://github.com/neaumusic/selection-highlighter/issues/22 for page freeze test..

neaumusic commented 1 year ago

I'm gonna close this one! I made some drastic performance improvements for chrome, using the Highlight API to highlight text, and a single canvas to draw the markers. Regex is still a bit expensive on large documents, but not nearly as much as DOM manipulations.

Just submitted v3.0.0 to the chrome store, let me know if anyone has issues, seems to work ok in the stress test