12
$\begingroup$

When typing text with a lot of equations, the update is terribly slow in proportion to the number and complexity of the equations displayed. It even gets updated when typing in a single character. it's got to the point where I have to type the answer in a text editor and then pasted it into the text screen here.

How do you get around this problem?

$\endgroup$
  • 4
    $\begingroup$ So far I have just been suffering, so I'm looking forward to any good answers that appear. $\endgroup$ – dmckee Jul 28 '11 at 1:02
  • $\begingroup$ Same here. (Well, my solution is "have a fast computer" but that's not exactly ideal :-P) $\endgroup$ – David Z Jul 28 '11 at 1:12
  • $\begingroup$ Have the same problem on my netbook. Could we get a checkbox beneath the text area to toggle the live preview (or just the latex) on/off? Guess that would be the easiest solution. PS: Otherwise, I love MathJax! $\endgroup$ – jdm Aug 3 '11 at 20:28
3
$\begingroup$

The rendering of the preview, and of the MathJax latex equations, is all on the browser, so as @David Zaslavsky says, it's all down to the browser's javascript engine, with Chrome's being the fastest at time of writing.

[edit]

I appreciate that there used to be a 3-second delay between the end of typing and the re-rendering of the preview, and is now much shorter.

But how about changing the javascript preview, so that it actually times itself, measuring how long the whole preview-refresh takes, regardless of how many incidences of Mathjax markup there are? Then if it's slow, it can use the 3s delay ; if it's fast, it can use the 0.5s delay

[end edit]

Now, it might be possible to implement a delay between the end of the last keypress, and a re-rendering of the preview, via a client-side script, in Greasemonkey or the Chrome / Opera user scripts, by hijacking the stackexchange preview function, building the delay in, and then handing back to the stackexchange javascript if the N seconds pass without further keypresses.

I just had a prod around in the javascript source code. It seems that when there are five or more equations, it will build in a small delay before rendering. So maybe if you've got 4 equations, add an extra empty equation or two, and then just keep typing and don't leave more than half a second between keypresses (NB I haven't tried this out, so it may not work! I've just gleaned what appears to be supposed to be happening, from the source)

$\endgroup$
  • $\begingroup$ But the problem of it redisplaying every single equation every time a is key pressed would still be there. $\endgroup$ – John McVirgo Jul 29 '11 at 13:15
  • $\begingroup$ No, what I have in mind is that it only re-renders a preview if there's been no key pressed for 3 seconds. So, if you make one keypress every second for ten seconds, then stop, it would only do one preview; and that would be at 13 seconds after you started typing. $\endgroup$ – EnergyNumbers Jul 29 '11 at 13:27
  • $\begingroup$ Pseudocode added to answer to clarify $\endgroup$ – EnergyNumbers Jul 29 '11 at 13:34
  • $\begingroup$ I think having a preview button beside the post button would be better and simpler. $\endgroup$ – John McVirgo Jul 29 '11 at 13:42
  • $\begingroup$ Yes, that could be doable in a Greasemonkey / userscript too. What browser (& which version) are you using? $\endgroup$ – EnergyNumbers Jul 29 '11 at 13:45
  • $\begingroup$ I'm using IE8, but use Chrome and Firefox when the need arises. $\endgroup$ – John McVirgo Jul 29 '11 at 14:56
  • 1
    $\begingroup$ Ah, ok. Well, I guess the non-entirely-satisfactory workaround is to use Chrome when writing / editing posts with lots of latex. And the better workaround will be a javascript hack. If I ever get around to that hack, I'll post back here. (however, P[me finding time] << 1) $\endgroup$ – EnergyNumbers Jul 29 '11 at 15:05
  • 2
    $\begingroup$ As I recall, the preview box used to use a delay of about 3 seconds for rendering equations, regardless of how many there were. Then at some point they changed it to the current instant-update scheme. $\endgroup$ – David Z Jul 29 '11 at 23:13
  • 1
    $\begingroup$ @david that's the ironic thing here.. proposing the old behavior be returned :) $\endgroup$ – Jeff Atwood Jul 30 '11 at 9:12
  • $\begingroup$ How about the javascript actually timing how long its preview-refresh takes? Then if it's slow, it can use the 3s delay ; if it's fast, it can use the 0.5s delay $\endgroup$ – EnergyNumbers Jul 30 '11 at 9:52
2
$\begingroup$

I think it's more likely to be slowed by the specific browser you're using rather than computer speed, installing the latest browser (of your choice) should help. MathJax was recently implemented and discussed on this blog. You may find some of the post and/or comments there useful.

$\endgroup$
  • 1
    $\begingroup$ The entire page with all its equations is updated for every single character entered and that appears to be the main problem, rather than speed of browser. I've found that Google Chrome is the fastest, followed by Firefox and then IE. $\endgroup$ – John McVirgo Jul 28 '11 at 14:00
  • $\begingroup$ Interesting @John, I wasn't aware that was the case. If so, would that not imply that the quality of one's internet connection is likely to be the most limiting factor? $\endgroup$ – qftme Jul 28 '11 at 14:13
  • $\begingroup$ my internet connection can stream HD video into my browser. The problem is a combination of how quickly the browser can display mathjax, and how the stackexchange software on the server side can efficiently display text as its updated. I think a preview button is all that's needed $\endgroup$ – John McVirgo Jul 28 '11 at 15:12
  • 1
    $\begingroup$ Actually, the preview rendering is all done client-side, in Javascript, so the speed of your internet connection generally isn't a factor. It really just depends on how fast your browser's Javascript interpreter works, which is a function of the implementation of the interpreter (Chrome is currently the fastest by a small margin, AFAIK) and the speed of your computer. $\endgroup$ – David Z Jul 28 '11 at 17:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .