# Pony request: MathJax August 4, 2019 3:00 PM Subscribe

I like talking about math with other Mefites on MetaFilter. There have been several threads over the last few months in which I enjoyed the conversation, but found the lack of ability to use properly-typeset formulas really cumbersome. I don't think this should be a particularly high priority, especially considering other issues the site is working on right now, but I'd really love the ability to use MathJax on MetaFilter.

This issue was raised previously in 2011 (focused on MathML rather than MathJax specifically), and at the time the answer was a pretty firm "no," with good justifications. But both Web technologies and the MetaFilter community have changed significantly since then.

MathJax renders properly in all major browsers, and my impression is the dev overhead for implementing it is now considerably lower than it was then. I also think that it is now unlike other "special" features that might be requested for MetaFilter in that it is an extremely mature library, and has become the de facto standard for writing mathematics on the Web. Input can be either the LaTeX subset supported by MathJax, which the hardcore math nerds are probably more used to, or AsciiMath, which is much more approachable for the casual mathematics aficionado.

MathJax also includes features addressing accessibility, which was my biggest concern when considering proposing this again; I am not sure how exactly it deals with, e.g., screen readers, but it at least appears to attempt to tackle the issue. If anyone has direct experience with this it would be valuable to hear.

Is there broad enough community interest in this feature? Is my impression correct that the dev barrier to implementation now sufficiently low as to be worth reconsidering?

(I searched and found no references to MathJax on MetaTalk other than the 2011 discussion; apologies if this has been raised again and I missed it!)

This issue was raised previously in 2011 (focused on MathML rather than MathJax specifically), and at the time the answer was a pretty firm "no," with good justifications. But both Web technologies and the MetaFilter community have changed significantly since then.

MathJax renders properly in all major browsers, and my impression is the dev overhead for implementing it is now considerably lower than it was then. I also think that it is now unlike other "special" features that might be requested for MetaFilter in that it is an extremely mature library, and has become the de facto standard for writing mathematics on the Web. Input can be either the LaTeX subset supported by MathJax, which the hardcore math nerds are probably more used to, or AsciiMath, which is much more approachable for the casual mathematics aficionado.

MathJax also includes features addressing accessibility, which was my biggest concern when considering proposing this again; I am not sure how exactly it deals with, e.g., screen readers, but it at least appears to attempt to tackle the issue. If anyone has direct experience with this it would be valuable to hear.

Is there broad enough community interest in this feature? Is my impression correct that the dev barrier to implementation now sufficiently low as to be worth reconsidering?

(I searched and found no references to MathJax on MetaTalk other than the 2011 discussion; apologies if this has been raised again and I missed it!)

I think this would be very cool, although I do wonder if it would lead to a certain amount of obnoxious/annoying behavior in non-math-related threads. That could be tackled either socially through expected behavioral norms, or technically by only enabling it in certain threads (e.g. ones tagged "math" or whatever). But either way I think the community should think about it upfront.

posted by Kadin2048 at 3:48 PM on August 4, 2019 [4 favorites]

posted by Kadin2048 at 3:48 PM on August 4, 2019 [4 favorites]

*as dev priorities go it'd be in the back of a long list*

That would certainly be my expectation. My

*hope*is that it's lightweight enough of a change that it would make it through triage anyway, but even if there's enough interest in the community (other than by me) that there's a decision to do it, I wouldn't expect to see it any time soon.

Here are a few recent threads I can recall where I would have liked to be able to use properly formatted math in the discussion:

Great. Now I'm even uncertain about how uncertain I should be

There can be only 1

Cat and Mouse

(Incidentally, in finding the links for those, I discovered that just looking up the "math" tag reveals an absolute treasure trove of FPPs.)

posted by biogeo at 4:14 PM on August 4, 2019 [2 favorites]

If we do this just make it universally available. Like the zagato crap nefarious use can be easily be handled socially/by mods.

posted by Mitheral at 4:56 PM on August 4, 2019 [2 favorites]

posted by Mitheral at 4:56 PM on August 4, 2019 [2 favorites]

*Zagato? Only reference I can find is this.*

Maybe they meant to say Z͇̘a̭̳͈͓̻̬l̢͓̲̯g͕̯̮̫̦͡o҉̩̝?̤͔̣͚̻̞͙

posted by Jpfed at 7:52 PM on August 4, 2019 [5 favorites]

I definitely decided not to drop more knowledge on Bayesian updates in the recent replication crisis thread on account of not being able to properly express formulae. But it's definitely not a pain I feel often.

posted by kaibutsu at 9:02 PM on August 4, 2019 [6 favorites]

posted by kaibutsu at 9:02 PM on August 4, 2019 [6 favorites]

I don't think I'd use this feature often, but sure, there are circumstances when I would.

posted by Joe in Australia at 10:25 PM on August 4, 2019

posted by Joe in Australia at 10:25 PM on August 4, 2019

I would definitely use this on the occasional maths comment, I think.

posted by Proofs and Refutations at 1:54 AM on August 5, 2019 [1 favorite]

posted by Proofs and Refutations at 1:54 AM on August 5, 2019 [1 favorite]

As far as I can tell, adding support for MathJax consists of a single step: add the Javascript import to the html header. That’s it! jsbin example.

It would definitely be a "nice-to-have" feature.

According to the MathJax website, the default configurations all include accessibility options for screen readers etc.

posted by pharm at 3:48 AM on August 5, 2019 [4 favorites]

It would definitely be a "nice-to-have" feature.

According to the MathJax website, the default configurations all include accessibility options for screen readers etc.

posted by pharm at 3:48 AM on August 5, 2019 [4 favorites]

Is it available as a browser extension something like that, so that people could just start using LaTeX or AsciiMath—perhaps concealed in a <details/> tag for modesty's sake—and the community can essentially test everything out before mods have to get involved and modify the site's code?

posted by XMLicious at 5:54 AM on August 5, 2019 [1 favorite]

posted by XMLicious at 5:54 AM on August 5, 2019 [1 favorite]

I have no say in the administration of MF but one of the things I like about it is the nice lightweight design. Adding an additional javascript file is easy enough on the server side but pushes additional requirements onto everyone else to actually run the code.

Does the need for mathematical equations arise so often that everyone needs to load hundreds of lines of JS? MathJax looks pretty neat but I am against it unless there is a huge dam of mathematical content that we are missing out on.

posted by AndrewStephens at 6:16 AM on August 5, 2019 [3 favorites]

Does the need for mathematical equations arise so often that everyone needs to load hundreds of lines of JS? MathJax looks pretty neat but I am against it unless there is a huge dam of mathematical content that we are missing out on.

posted by AndrewStephens at 6:16 AM on August 5, 2019 [3 favorites]

Note that Metafilter would definitely need to use the Safe extension as otherwise commentators could include javascript links & mess with css amongst other things.

posted by pharm at 6:40 AM on August 5, 2019 [3 favorites]

posted by pharm at 6:40 AM on August 5, 2019 [3 favorites]

The MathJax JS lib is less than 15kB, and gets cached by the browser so you're only transferring it once per session. With a well-crafted configuration file the whole thing can be under 20-25 kB. I understand the fight against web bloat, but this doesn't seem like the hill to die on. In a big discussion thread, we probably burn more bits on Oxford commas. (Okay, maybe not quite, but I bet we get close.)

I use

posted by Kadin2048 at 7:00 AM on August 5, 2019 [2 favorites]

I use

*ancient*hardware (e.g. my IBM T41 laptop / melee weapon) at home and, when put into perspective against anything else on the modern web, one sub-20kB library--particularly one that adds meaningful functionality--is not going to be the straw that breaks that particular camel's back. Anyone using hardware so limited that they're going to have a sudden problem on account of MathJax is, basically by necessity because of what happens anytime you click on*literally any off-site link*, going to be using some sort of script/contentblocker for the rest of the web, for it to be usable. They could add MathJax to it, if they really wanted to, although my personal experience suggests that you are better off blocking images on the modern web than JS, if you need to start cutting.posted by Kadin2048 at 7:00 AM on August 5, 2019 [2 favorites]

Welllll. Sorta.

The full MathJax JS is something like 5-8Mb, but it’s fairly modular: the initial script checks to see what source + layout extensions it needs before loading anything else + only loads exactly what it needs. So if there’s no math on the path, then nothing is loaded etc etc. Also, all the JS + fonts can be cached (+ if you load them from the main CDN probably already are.)

Render speed is not quick if there’s a lot of maths on the page though - KaTeX (developed by Kahn academy) is something like 10x quicker & might be more appropriate for Metafilter. It’s also safe by default if I read the documentation correctly, which is a plus over MathJax. It’s not as powerful as MathJax, but I doubt Metafilter users would care about the missing features. From an accessibilty POV, KaTeX can generate MathML, which can in turn be read by the major web screen readers IIRC.

posted by pharm at 7:32 AM on August 5, 2019 [3 favorites]

The full MathJax JS is something like 5-8Mb, but it’s fairly modular: the initial script checks to see what source + layout extensions it needs before loading anything else + only loads exactly what it needs. So if there’s no math on the path, then nothing is loaded etc etc. Also, all the JS + fonts can be cached (+ if you load them from the main CDN probably already are.)

Render speed is not quick if there’s a lot of maths on the page though - KaTeX (developed by Kahn academy) is something like 10x quicker & might be more appropriate for Metafilter. It’s also safe by default if I read the documentation correctly, which is a plus over MathJax. It’s not as powerful as MathJax, but I doubt Metafilter users would care about the missing features. From an accessibilty POV, KaTeX can generate MathML, which can in turn be read by the major web screen readers IIRC.

posted by pharm at 7:32 AM on August 5, 2019 [3 favorites]

this pony, i'd ride it

posted by dismas at 8:12 AM on August 5, 2019 [4 favorites]

posted by dismas at 8:12 AM on August 5, 2019 [4 favorites]

I was unaware of KaTeX, so it's probably worth clarifying that I see this as a request for what MathJax

Also, in the off chance that any of the higher-priority items on the site development list include an overhaul of comment formatting to include something similar to Markdown syntax, a lot of Markdown renderers already incorporate MathJax, as well.

posted by biogeo at 11:40 AM on August 5, 2019 [3 favorites]

*achieves*in terms of communicating mathematics rather than necessarily MathJax specifically. Alternative solutions are certainly fine if they are more technically suitable. One reason to prefer MathJax is its near-ubiquity (at least that is my perception), so I feel there's possibly less risk than going with a less-used option, but that may not be an accurate perception.Also, in the off chance that any of the higher-priority items on the site development list include an overhaul of comment formatting to include something similar to Markdown syntax, a lot of Markdown renderers already incorporate MathJax, as well.

posted by biogeo at 11:40 AM on August 5, 2019 [3 favorites]

(One more for the 'for' column: we would also be technologically ahead of Hacker News.)

posted by kaibutsu at 3:51 PM on August 5, 2019 [2 favorites]

posted by kaibutsu at 3:51 PM on August 5, 2019 [2 favorites]

I really like being able to read metafilter on my phone with javascript completely disabled (much better battery life than using a selective script blocker) so I don't love this idea.

posted by A Thousand Baited Hooks at 4:46 PM on August 5, 2019 [2 favorites]

posted by A Thousand Baited Hooks at 4:46 PM on August 5, 2019 [2 favorites]

Wouldn't Mathjax with JavaScript disabled just look like regular Tex? I.e., something like $a=\sum_{i=1}^_{n}i$?

posted by Joe in Australia at 5:14 PM on August 5, 2019

posted by Joe in Australia at 5:14 PM on August 5, 2019

Yes. Which might be an argument for enabling only AsciiMath, since the text-only fallback is more human-readable. AsciiMath is less full-featured than MathJax-flavored LaTeX, but probably covers 90%+ of use cases for the already fairly infrequent use case of math typesetting.

Examples of how the quadratic formula would be entered:

AsciiMath: `x = (-b +- sqrt(b^2 - 4ac)) / (2a)`

LaTeX: $x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$

MathJax renders both of those identically, but for those with JavaScript turned off, AsciiMath is much easier to read; almost unnoticeable that there's a special syntax being used, in fact. For more complex examples, AsciiMath is maybe less appreciably easier to parse than LaTeX; Joe in Australia's example would be `a = sum_(i=1)^n i`, which is basically the same thing as LaTeX but without the backslashes and with parentheses instead of braces.

Perhaps turning off MathJax (or other Javascript math typesetting) could be an option for logged-in users?

posted by biogeo at 7:24 PM on August 5, 2019

Examples of how the quadratic formula would be entered:

AsciiMath: `x = (-b +- sqrt(b^2 - 4ac)) / (2a)`

LaTeX: $x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$

MathJax renders both of those identically, but for those with JavaScript turned off, AsciiMath is much easier to read; almost unnoticeable that there's a special syntax being used, in fact. For more complex examples, AsciiMath is maybe less appreciably easier to parse than LaTeX; Joe in Australia's example would be `a = sum_(i=1)^n i`, which is basically the same thing as LaTeX but without the backslashes and with parentheses instead of braces.

Perhaps turning off MathJax (or other Javascript math typesetting) could be an option for logged-in users?

posted by biogeo at 7:24 PM on August 5, 2019

I would get a kick out of it, it would be neat, but I feel like there's just no way it can be worth the security risk and maintenance.

and tbh I can't think of any time I'd wished someone

posted by fleacircus at 8:12 PM on August 5, 2019

and tbh I can't think of any time I'd wished someone

*else*had access to this library for their comment..posted by fleacircus at 8:12 PM on August 5, 2019

MathJax is great and is indeed easy to implement in my limited experience. That said, I'm a mathematician and I can think of maybe two times when I would have used MathJax on MeFi. I'd prefer TPTB focus on other priorities.

posted by dbx at 8:41 PM on August 5, 2019 [1 favorite]

posted by dbx at 8:41 PM on August 5, 2019 [1 favorite]

Does it need to go off to other sites to pull in code? If so,

Also, you can do this fairly easily with a Compose key/WinCompose: x = (-b ± √(b² - 4ac)) / 2a. That ASCIIMath (aside from the grating missing ‘s’) misusing +- to mean ± is just nooooooooooooooooooope.

posted by scruss at 5:25 AM on August 6, 2019

*hard*nope. The occasional comment can use`<pre>`

maths for clarity.Also, you can do this fairly easily with a Compose key/WinCompose: x = (-b ± √(b² - 4ac)) / 2a. That ASCIIMath (aside from the grating missing ‘s’) misusing +- to mean ± is just nooooooooooooooooooope.

posted by scruss at 5:25 AM on August 6, 2019

Google is a bunch of jerks for refusing to implement MathML in Chrome, and making kludges like MathJax necessary.

posted by 1970s Antihero at 8:55 AM on August 6, 2019 [2 favorites]

posted by 1970s Antihero at 8:55 AM on August 6, 2019 [2 favorites]

There are plenty of samples on CodePen that use MathJax, so that could be one avenue to explore - it would mean linking people off to a separate site which breaks the flow of conversation, but it's better than nothing.

posted by Lanark at 10:26 AM on August 6, 2019

posted by Lanark at 10:26 AM on August 6, 2019

I think it's worth exploring, and testing specifically with mobile browsers.

posted by ZeusHumms at 10:50 AM on August 6, 2019

posted by ZeusHumms at 10:50 AM on August 6, 2019

>

The total MathJax load in the page linked from pharm's comment is around 173 KB, including JS and font files. Which isn't terrible, but it's considerably more than 20 KB. Although the main slowdown induced by Javascript rendered content isn't even necessarily the byte weight, it's the computational time needed to reflow a rendered page. Which probably won't be bad in short threads (and would be pretty trivial if users had the option to turn off imported fonts) but risks getting pretty awful in long threads.

posted by ardgedee at 12:55 PM on August 6, 2019 [1 favorite]

*The MathJax JS lib is less than 15kB, and gets cached by the browser so you're only transferring it once per session. With a well-crafted configuration file the whole thing can be under 20-25 kB. I understand the fight against web bloat, but this doesn't seem like the hill to die on.*The total MathJax load in the page linked from pharm's comment is around 173 KB, including JS and font files. Which isn't terrible, but it's considerably more than 20 KB. Although the main slowdown induced by Javascript rendered content isn't even necessarily the byte weight, it's the computational time needed to reflow a rendered page. Which probably won't be bad in short threads (and would be pretty trivial if users had the option to turn off imported fonts) but risks getting pretty awful in long threads.

posted by ardgedee at 12:55 PM on August 6, 2019 [1 favorite]

Does MathML work if you use Firefox, or does metafilter strip out the tags altogether?

$\frac{x+{y}^{2}}{k+1}$

posted by Pyry at 1:34 PM on August 6, 2019 [3 favorites]

$\frac{x+{y}^{2}}{k+1}$

posted by Pyry at 1:34 PM on August 6, 2019 [3 favorites]

Well, it's not the most beautiful math rendering I've ever seen, but it does work in Firefox, so problem solved: everyone should just use Firefox.

posted by Pyry at 1:39 PM on August 6, 2019 [6 favorites]

posted by Pyry at 1:39 PM on August 6, 2019 [6 favorites]

It also works in mobile Safari

posted by Huffy Puffy at 4:37 PM on August 6, 2019 [3 favorites]

posted by Huffy Puffy at 4:37 PM on August 6, 2019 [3 favorites]

Seconding works in mobile safari, at least on my outdated ipad

posted by one4themoment at 4:58 PM on August 6, 2019

posted by one4themoment at 4:58 PM on August 6, 2019

This is a bit of a digression, but I'd note that even if/when it becomes fully supported by Chrome, Edge, and Opera, MathML by itself isn't really a full solution for math communication. Just as a personal opinion, it's really kind of a crappy standard, which is probably why implementation hasn't been anyone's priority since it was first proposed back in the '90s, or since it was adopted as an HTML5 standard in 2015. No one wanting to write math is going to do it in MathML, because it's so ridiculously verbose, and the markup itself is practically unreadable for anything more than really simple examples. I'd be rather surprised if even once all browsers support it, MathML ends up actually finding wide use by people doing math on the Web.

There's also no graceful no-rendering fallback for MathML: Chrome presents

Anyway, that said, if and when MathML does actually manage to become supported by all major browsers, maybe those of us wanting to use properly-typeset math could just get a script or something to convert some actual sane standard into MathML client-side when composing a comment. We'd probably need to revisit the question of how well MathML is actually rendered by the various browsers to ensure we're not accidentally excluding some people from discussions by using it, though.

posted by biogeo at 11:55 PM on August 6, 2019

There's also no graceful no-rendering fallback for MathML: Chrome presents

**Pyry**'s example as "x+y2k+1". I have no idea what that is supposed to be without looking at the raw markup, and after looking at it, "x+y2k+1" seems to be the "correct" rendering for a browser that doesn't recognize the MathML tags, which is a pretty bad default behavior. Right now, if someone were to use MathML in a discussion, some fraction of people (those using Firefox, Safari, and apparently Blackberry, according to caniuse.com) would see what was intended, while everyone else (those using Chrome, Opera, Edge, or anything else) would see gibberish. So at the moment I don't think people should use it.Anyway, that said, if and when MathML does actually manage to become supported by all major browsers, maybe those of us wanting to use properly-typeset math could just get a script or something to convert some actual sane standard into MathML client-side when composing a comment. We'd probably need to revisit the question of how well MathML is actually rendered by the various browsers to ensure we're not accidentally excluding some people from discussions by using it, though.

posted by biogeo at 11:55 PM on August 6, 2019

I have tried to write formulas both on the main site and, believe it or not, on Ask, so I think this is a cool idea. I would prefer something with LaTeX syntax over AsciiMath since, purely selfishly, I don't want to have to learn another formula typesetting language. LaTeX may be a little verbose, but it is also something that I imagine most people who would ride this pony would already at least know a little about.

posted by en forme de poire at 11:56 PM on August 6, 2019 [4 favorites]

posted by en forme de poire at 11:56 PM on August 6, 2019 [4 favorites]

Cursory googling turns up a CSS stylesheet intended to improve the default rendering of MathML in browsers which don't support it.

posted by XMLicious at 3:10 AM on August 7, 2019 [1 favorite]

posted by XMLicious at 3:10 AM on August 7, 2019 [1 favorite]

I've wanted MathJax for ages. Just not sure when and how to enable it. Can you use it in post titles? above the fold? or just in the per-post view? below the fold? comments only? only on Ask? only in posts tagged mathjax?

I think it would be fine to only turn it on in 'mathjax' tagged posts and only on the full post view. People can MeMail the OP to add the tag if it's missing. See how that works out.

On the whole, I think the closer you can come to presenting things in the same way one would see it in a textbook or a relevant paper the easier it is to understand. Trying to cram it into a per-person random notation using ASCII (or Unicode) that isn't just raw MathJax/LaTeX in the first place just takes you back to the middle ages where every scientist had their own incompatible notation for the same thing. We settle on a relatively uniform way of presenting these things for a reason.

It's like YAY!, now we don't worry that much about people not having Unicode fonts. Now it's time for YAY! they can see equations.

posted by zengargoyle at 12:39 PM on August 9, 2019 [1 favorite]

I think it would be fine to only turn it on in 'mathjax' tagged posts and only on the full post view. People can MeMail the OP to add the tag if it's missing. See how that works out.

On the whole, I think the closer you can come to presenting things in the same way one would see it in a textbook or a relevant paper the easier it is to understand. Trying to cram it into a per-person random notation using ASCII (or Unicode) that isn't just raw MathJax/LaTeX in the first place just takes you back to the middle ages where every scientist had their own incompatible notation for the same thing. We settle on a relatively uniform way of presenting these things for a reason.

It's like YAY!, now we don't worry that much about people not having Unicode fonts. Now it's time for YAY! they can see equations.

posted by zengargoyle at 12:39 PM on August 9, 2019 [1 favorite]

I'm not convinced it should be a high priority for Metafilter, but I'm glad to know about this for other things. Thanks!

posted by eotvos at 8:41 AM on August 10, 2019

posted by eotvos at 8:41 AM on August 10, 2019

Metafilter mathematicians unite! This would be nifty. Definitely, if we were to do it, let’s have LaTeX syntax.

posted by leahwrenn at 10:47 PM on August 12, 2019

posted by leahwrenn at 10:47 PM on August 12, 2019

You are not logged in, either login or create an account to post comments

Quick expectation setting: I'd need to take a close look with frimble about what would be involved in supporting it well before we could even consider it, and as dev priorities go it'd be in the back of a long list, so I think it's unlikely we'd even really have a "can we?" answer any time soon let alone a "will we?"

That said, I don't mind people talking about it, and maybe identifying examples of actual use cases where it would have made a difference to them in how they've dealt with comments or answers in the last few years.

posted by cortex (staff) at 3:04 PM on August 4, 2019 [1 favorite]