31
$\begingroup$

In view of the nearly unbearable slowdowns I experience while composing answers (both in Safari 5 and Firefox 5 on OS X 10.6.7) since June 21/22 I would most welcome a possibility to reverse this state, at least locally on my machine.

The easiest possibility (from the user perspective) would probably be to introduce a user option where one could choose between the options of:

  • instant rendering,
  • a rendering delay of $5$ seconds (as it was some weeks ago),
  • turn automatic MathJax rendering off entirely

while composing questions and answers. If the last option should happen to be implemented, a button "one shot preview" as on MathOverflow would be very nice.

I tried to adapt the user script by KennyTM given here, but lacking JavaScript expertise I was unable to do that. If someone could provide a solution involving Greasemonkey that would be fine with me, too. Some hints or indications on how to implement such a user script would also be appreciated, of course.

$\endgroup$
6
  • $\begingroup$ Also, if rendering isn't instant, it would be nice to have some easily typed command that immediately initiates rendering, so one doesn't have to suffer delays. Perhaps one could even set the delay as the time between two commands, or somesuch. $\endgroup$ Commented Jul 10, 2011 at 21:13
  • $\begingroup$ I think the actual problem is that currently when one changes one formula, many other formulas get re-parsed. Fixing it would be an easy performance optimization, right? :) $\endgroup$ Commented Jul 17, 2011 at 10:49
  • $\begingroup$ Also a problem for me on latest version of Chrome on OS X 10.6.8. My guess (based on the age of the laptop I am on) is that this is a wimpy-hardware issue rather than a browser issue. $\endgroup$ Commented Jul 17, 2011 at 11:43
  • 1
    $\begingroup$ @Carl: I don't think it is. I've got a pretty new (1 year old) MacBook Pro. If indeed the site requires stronger hardware than that, then there is a serious design problem. $\endgroup$
    – t.b.
    Commented Jul 17, 2011 at 11:57
  • $\begingroup$ @Theo: that's interesting, since I always blamed it on my old laptop. If the site can't run on that hardware then there is certainly something amiss. I wonder whether the same thing happens on Windows? Unfortunately I don't have any way to check. $\endgroup$ Commented Jul 17, 2011 at 12:56
  • $\begingroup$ +1 for option to turn off MathJax and +10 for the one-shot preview. I am using FireFox 3.6.24 on MacOSX 10.4: MathJax is really slow for me. $\endgroup$
    – Sam Nead
    Commented Nov 26, 2011 at 16:16

2 Answers 2

20
$\begingroup$

I don't know how you want to do user scripts. I use bookmarklets mostly.

To pause it:

javascript:(function(){MathJax.Hub.queue.pending=1;})();

To turn it back on:

javascript:(function(){MathJax.Hub.queue.pending=0;})();

Presumably something similar can be done with automatic solutions like greasemonkey. The turn-it-back-on does not request an immediate render, but you can add the:

MathJax.Hub.Queue(["Typeset", MathJax.Hub, "wmd-preview"])

to the bookmarklet yourself if you'd like. Turning it back on may cause a delay; if so I can adjust the script to more drastically disable mathjax.

$\endgroup$
8
  • $\begingroup$ I don't know how people normally trade bookmarklets. I just put them at the bottom of my homepage. Just drag the links to the area of the browser right below the addressbar (called the "bookmarks bar") and you have a button. LtT turns it off. MJWMD turns it on. Both only work on stackexchange (or sites using the same markdown processor). $\endgroup$ Commented Jul 15, 2011 at 16:56
  • $\begingroup$ Thank you so much! This seems to work the way I wanted it to. Let me try it a bit before I accept your answer. $\endgroup$
    – t.b.
    Commented Jul 15, 2011 at 18:00
  • 2
    $\begingroup$ That's perfect and works like a charm, you can't even start imagining how much better the site feels to me now. Thanks again! I decided not to accept your answer since I still hope for a feature that allows me to turn this off without resorting to such tricks. $\endgroup$
    – t.b.
    Commented Jul 16, 2011 at 8:56
  • 1
    $\begingroup$ No problem. MediaWiki (wikipedia etc.) lets you install your own personal javascript on the site (that only loads for you). This is very handy for customizing things. Perhaps something similar will happen for stackexchange. $\endgroup$ Commented Jul 16, 2011 at 14:01
  • $\begingroup$ The joy is over already :( they seem to have replaced the postRenderHtmlHook definition by a direct call editorObject.hooks.chain("onPreviewRefresh", function () { MathJax.Hub.Queue(["Typeset", MathJax.Hub, "wmd-preview"]); }); which I don't know how to suppress. $\endgroup$
    – t.b.
    Commented Jul 17, 2011 at 1:57
  • $\begingroup$ The new method no longer exposes the markdown converter, but you can tell mathjax to take a break processing its queue. Things still get added to the queue, so this is very friendly, but maybe when you turn the queue back on it will still hang your browser (mine are fine). If this is a problem, let me know since it is easy to (a) disable adding things to the queue, and (b) empty the queue without processing. However, these are a bit more drastic. New script works on any mathjax site. $\endgroup$ Commented Jul 17, 2011 at 9:19
  • $\begingroup$ Thank you yet again, your new solution again achieves what I need. Never mind about Greasemonkey, I was simply unaware of the possibility of using bookmarklets in this way. $\endgroup$
    – t.b.
    Commented Jul 17, 2011 at 12:37
  • $\begingroup$ I reposted these instructions on MO. Please let me know if something needs modification, and thanks for having provided this solution. $\endgroup$
    – quid
    Commented Dec 22, 2015 at 23:40
6
$\begingroup$

Here's a solution that involves quite a few more mouse-clicks. If you right-click something rendered by MathJax, like $$\text{Right-Click Me!}$$ and select Math Settings > Math Renderer > Plain Source, that'll display the MathJax just as the LaTeX code which you've typed, so MathJax won't do any work. This is much faster than letting MathJax render the nice math each time, and then after finishing a draft, right-click again and select Math Settings > Math Renderer > HTML-CSS or something to ensure that everything is rendering as you suspect.

It should be noted that this setting is persistent; if you select Math Settings > Math Renderer > Plain Source, close your tab, then reopen another MathSE page, the MathJax will still render in Plain Source.

$\endgroup$
2
  • $\begingroup$ This looks as though it could be incredibly helpful. I'm mostly posting from my phone and the problem isn't just slowdowns—it's the keyboard disappearing from the screen for memory reasons, words I've typed not getting into the text, or occasionally, the whole browser crashing. Obviously these things happen just as I've found some hideous error in one of my posts and am eager to correct it ASAP . . . $\endgroup$
    – timtfj
    Commented Dec 27, 2018 at 22:34
  • 1
    $\begingroup$ See also stackoverflow.com/questions/36815367/… with example bookmarklet for changing renderers $\endgroup$
    – Vadzim
    Commented Jan 25, 2019 at 19:54

You must log in to answer this question.

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