Autoload MathJax - regex, global or element (v6)

VERSION 6: Here, we're autoloading MathJax if:

  1. The script finds any math via regex matching; OR
  2. The value JXG.Options.text.useMathJax is set to true; OR
  3. Any text element has useMathJax = true;

You can test various scenarios in this script (by commenting out or not the following in the source code):

  1. User provides a MathJax configuration (or doesn't). If they haven't, the fourth expression won't be typeset because it's in single $...$ delimiters.
  2. MathJax is already loaded before JSXGraph scripts run, so no need to autoload (or not)
  3. There is a window "load" eventListener (or not)
  4. User specifies useMathJax: true and parse: false (or not)

On this example page, we see SOME instances of JSXGraph's default "MathJax (not yet) loaded" in the console, since we are waiting until MathJax is loaded and ready before it typesets the math. When something like this code block is within JSXGraph, I believe those notifications will be gone.