Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving performance #459

Closed
nehalist opened this issue Aug 22, 2020 · 1 comment
Closed

Improving performance #459

nehalist opened this issue Aug 22, 2020 · 1 comment
Labels
🙋 no/question This does not need any changes

Comments

@nehalist
Copy link

Currently the performance of this package is really torturing my browser as soon as the parsed markdown gets too big. It's easily reproducible by taking a look at the demo at https://github.com/uiwjs/react-markdown-editor which depends on this package. Just duplicate the editor content a few times and witness your browser giving its best trying not to die.

I initially thought the reason for this is CodeMirror, but as soon as the preview is disabled (not just hidden but literally removing the DOM element) everything works fine again.

Since having ~500 lines of content is not that rare these performance issues make it really hard to use this package. Is there any way to improve performance?

@ChristianMurphy
Copy link
Member

ChristianMurphy commented Aug 25, 2020

@nehalist react-markdown builds on https://github.com/remarkjs/remark, which will get parsing performance improvements with remarkjs/remark#439

However, even with parsing improvements, any parsing/processing will become computationally expensive given enough text.
A common approach to smoothing the experience is to apply a debounce (overview, lodash, react hook)
Which reduces overhead by not rendering for every keystroke, and instead rendering after a keystroke and after some number milliseconds pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙋 no/question This does not need any changes
Development

No branches or pull requests

2 participants