How to display math formulas on a webpage?

What are your guys’ favorite ways to display formulas in HTML without any additional website performance issues?

And preferably as text since it seems to be shown a lot more in search engines compared to SVG.

Use the math element.

Kim said:
Use the math element.

msup, mrow, mfrac, munderover

Getting some serious m’lady vibes.

Kim said:
Use the math element.

x = − b ± b 2 − 4 ⁢ a ⁢ c 2 ⁢ a

Amazing, the solution to a second-degree polynomial.

Kim said:
Use the math element.

I’m trying it out now actually.

Would you happen to know about any function to turn a JavaScript math expression into MathML?

I’m not quite getting it yet.

@Ellis

I’m not sure about power though; there seems to be a bug that you can’t use negative powers or more than 9.

I haven’t read the entire docs though.

Eli said:
@Ellis
https://www.mathjax.org/

I’m not sure about power though; there seems to be a bug that you can’t use negative powers or more than 9.

I haven’t read the entire docs though.

I’ve never encountered that before—have you tried wrapping your exponent, like this: {so}?

@Shiloh
Yeah, it did work.

Eli said:
@Ellis
https://www.mathjax.org/

I’m not sure about power though; there seems to be a bug that you can’t use negative powers or more than 9.

I haven’t read the entire docs though.

I thought you meant to just use the math element?

Like this:

<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>r</mi><mi>e</mi><mi>d</mi><mi>d</mi><mi>i</mi><mi>t</mi><mo>&#xA0;</mo><mo>+</mo><mo>&#xA0;</mo><msqrt><mrow><mi>u</mi><mi>p</mi><mi>v</mi><mi>o</mi><mi>t</mi><mi>e</mi><mo>&#xA0;</mo><mo>-</mo><mo>&#xA0;</mo><mi>d</mi><mi>o</mi><mi>w</mi><mi>n</mi><mi>v</mi><mi>o</mi><mi>t</mi><mi>e</mi></mrow></msqrt></math>

I tried MathJax in the past and experienced a significant reduction in website performance using it; that’s why I stopped and am looking at alternative ways.

Check out https://katex.org.

Kingsley said:
Check out https://katex.org.

It says on the website it’s fast, but is it true? I’ve tried 2 libraries, and they both sadly reduced my website’s performance. Trying to get MathML to work and see if it’s fast.