When answering JavaScript questions, I often include a handful of code snippets to accompany written descriptions. I've noticed that after two or three snippets, when I'm continuing to write the answer, the keyboard experiences a large input lag – I type some letters, and it takes over a second for them to appear on screen sometimes. This latency goes up as more snippets are added to the answer.
Here's an answer I'm writing right now where the problem is becoming unbearable https://stackoverflow.com/a/43195580/633183
Recreating the "bug" is a little difficult:
- Open the question: https://stackoverflow.com/a/43195580/633183
- Click the "edit" link
- Add some text in the textarea
- Click outside of the textarea to trigger a re-render on the answer preview (give Stack Overflow a couple of seconds to complete the render before re-focusing the textarea)
- Repeat steps 3 and 4 a bunch of times
- You will notice keyboard latency go way up - to a point where the textarea is literally unusable.
My suspicion is that there is some kind of memory leak when the answer preview renderer cleans up the stack snippets improperly. This issue only happens on answers where I include stack snippets.
For what it's worth, this is an old bug. I've been putting up with it for at least a year. It's possible it's been there since the beginning of stack snippets and I didn't notice right away.
Of the two browsers I have access to, Google Chrome is affected, but Safari is not. I have only tested on macOS. Another user reports experiencing this bug in Firefox.