clartaq / cwiki

A personal wiki written in Clojure/Script
Other
3 stars 0 forks source link

Is Editing Getting Slow on Long Pages? #11

Closed clartaq closed 4 years ago

clartaq commented 4 years ago

It seems like editing long pages, such as the "Work Notes" page, is becoming slow. I can get several characters ahead of the display without much effort now. That is really not good.

clartaq commented 4 years ago

Check if this is because of the "send-every-character" setting. Maybe that transmission is taking too long. Maybe it should occur whenever a save (including autosave) happens instead.

clartaq commented 4 years ago

For some time now, I have been dissatisfied with editing in CWiki. In particular, once a page gets to be about 30k characters or so, the editor cannot keep up with the keystrokes of a medium slow typist like me.

I originally thought it might be due to slow conversion to Markdown, syntax highlighting, MathJax, but then started to think about it some more.

It is more likely that using ClojureScript (or any other language using immutable data structures) is probably a bad thing to start with. Warning: This is all supposition with no effort made to actually benchmark where the program spends its time.

It would actually be a fun project to write an editor. But that would take forever and I'd probably end up with another crappy editor.

clartaq commented 4 years ago

After looking into this some more, the short answer is "yes". It seems to be an Inherent characteristic of basing the editor on the browser's texture element. (Or thecontent editable) mechanism.)

I looked into building with other, dedicated text editors like CodeMirror and EasyMDE. They performed just the same.

The culprit seems to be the live preview. (Again, using a CodeMirror or EasyMDE editor in place of the existing text control produced no improvement.) Just turning off the preview restores acceptable performance. I tested with files larger than anything I currently have in my wiki (about 75k characters) and performance was just fine. Turning the preview back on slowed things down again.

I will add a toggle to enable/disable the preview in the editor. to allow users to turn off the preview if needed if things get too slow or if they just prefer typing without distractions.

clartaq commented 4 years ago

Fixed this issue by adding an option to turn off real-time preview. Typing is responsive on long texts when the preview is turned off.