I experience a delay of about 5-10 seconds when I edit a question with math markup in https://math.stackexchange.com/.

However, there is no such delay in https://mathoverflow.net/.

Is there any setting to reduce or eliminate this delay in the former site? If not in the settings, is there a greasemonkey userscript that I can use? (I may be wrong but it seems to me that the LaTeX rendering is done on the client side - if so, there will be no pressure on server if this is implemented.)

  • 1
    $\begingroup$ By "when you edit a question," do you mean the periodic re-rendering of the TeX in the preview box? $\endgroup$ – Larry Wang Aug 20 '10 at 14:44
  • $\begingroup$ Exactly that's what I mean. And by delay I mean the period, i.e. time taken to remove the $ when I type "$x=1$" in the preview box. $\endgroup$ – KalEl Aug 20 '10 at 15:38
  • $\begingroup$ I see. Then it's a [feature-request] too (restored that tag). $\endgroup$ – kennytm Aug 20 '10 at 15:44
  • 1
    $\begingroup$ Thanks. I see my reply got all messed up, sorry for that. What I tried to type is "Exactly that's what I mean. And by delay I mean the period, i.e. time taken to remove the \$ when I type \$x=1\$ in the preview box." $\endgroup$ – KalEl Aug 20 '10 at 16:09

By default there is a 5-second delay before turning TeX code to equation, similar to Stack Overflow where the source code is syntax-colored.

You could use this userscript to reduce the waiting time to 0.5 seconds:

// ==UserScript==
// @name           Reduce equation preview time
// @namespace      http://networkpx.googlecode.com
// @description    Reduce equation preview time to 0.5 seconds on math.SE
// @include        https://math.meta.stackexchange.com/*
// @include        http://math.stackexchange.com/*
// ==/UserScript==

  • $\begingroup$ Oh, that's nice and kind of annoying! But less annoying then waiting 5 seconds. $\endgroup$ – Tom Stephens Aug 20 '10 at 16:33
  • 2
    $\begingroup$ @Tom: The delay can be adjusted by changing the "wait: 500" parameter (the unit is milliseconds). $\endgroup$ – kennytm Aug 20 '10 at 17:30
  • 2
    $\begingroup$ dude I tried this all night yesterday and couldn't just figure it out! You rock! $\endgroup$ – KalEl Aug 20 '10 at 18:24

I've been working on migrating MathOverflow to MathJax (from jsMath). One problem is that MathJax doesn't cache equations, which makes it slower for previews (where it has to re-render the same math many times). Here's a solution that I like much better than simply reducing the typeWatch wait time since it doesn't result in the annoying flickering of the math. You can permanently implement it by making it into a UserScript in the way KennyTM suggested.

wmdpreview     = document.getElementById('wmd-preview');
wmdpreview2    = document.createElement("div");
wmdpreview.id  = "wmd-preview-orig";
wmdpreview2.id = "wmd-preview"; // this is done to get the css right
var running = false;
  if (!running){ // don't do anything if MathJax is still working on the last one
    running = true;

This makes the preview a bit less responsive (a lot less responsive if you're writing a long post with lots of math), but it's much better than being responsive but visually distracting. Since you're just injecting the rendered math into the preview div after it's been processed, you don't get the MathJax control panel when you right click on math. It also messes up the rendering if you're using MathML instead of HTML-CSS for some reason.

  • 1
    $\begingroup$ So this creates a secondary preview which updates only after the primary one (which is hidden now) is done computing TeX. In effect it suppresses the intermediate output till TeX rendering is completed. Good solution, thanks! $\endgroup$ – KalEl Aug 24 '10 at 11:10

You must log in to answer this question.

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