Editor becomes unusably slow as post gets longer

I posted this post to a forum that uses Discourse:

And I also could reproduce this issue in the Demo forum.

That post contains long extracts of copy-pasted code - to be more precise, not exactly code but rather output from running commands. That’s a pretty common use case in support forums about software and computer stuff.

As I was writing the post, after pasting the long blocks of text (which aren’t even that long, just a few hundred lines), the editor became more and more sluggish while just typing. It took time to see the letters I type appear on screen (and I’m not talking about the live preview, just the very textarea you type into). It basically becomes unusable.

Nope. Discourse is free and open source software.

I am able to reproduce this when I copy/paste this into the editor. It indeed gets annoyingly sluggish.

3 Likes

Interesting, I can’t see to reproduce it here:

I see that this forum is behind on updates. Last week I merged a change that updates the HighlightJS library to it’s latest version, which will makes this a lot faster.

Also, the https://forum.manjaro.org instance has the setting autohighlight all code, which is not a good idea for a support forum where most posts with codeblocks will be simple log files and not actual code. I’d suggest their team to disable that ASAP.

Other than that, highlighting over 10k+ lines of code in the main browser thread will be perceptible slow on some devices, which is super easy to see when opening a GitHub diff on an Android phone. We have plans on making that happen in a background JS worker, but it has some drawbacks and we haven’t got to it yet.

3 Likes

Oh, my bad. On the home page I saw a big “try it free” button, which suggested that you can only try it for free, and in the Pricing section there was no mention of a free plan. I should have investigated further, I guess those are hosted plans or something.

Also, the https://forum.manjaro.org instance has the setting autohighlight all code

Yep I already noticed that and guessed it was probably a misconfiguration on their part, but that’s not relevant to the issue. I could have pasted an equally long piece of legitimate javascript code. Or even if the issue is actually triggered only by having code highlighted with the wrong syntax, that doesn’t justify the editor outside of the code becoming sluggish.

highlighting over 10k+ lines of code in the main browser thread will be perceptible slow on some devices

Yes but there’s no reason for that to be happening while I edit the rest of the post outside of the code block that is highlighted. Regardless of whether you do that in the main thread (obviously wrong - glad to hear you’re working on fixing that) or in the background, once the code has been highlighted and I’m no longer editing it, there shouldn’t be any highlight-related work to be done at all. Any parsing, computing etc related to highlighted only needs to be re-done if one modifies the contents of the code block.