{"record":{"id":"f03895e96eb5615d","repo":"plotly/plotly.js","slug":"unsupported-mathjax-version","errorCode":null,"errorMessage":"Unsupported MathJax version:","messagePattern":"Unsupported MathJax version:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/lib/svg_text_utils.js","lineNumber":229,"sourceCode":"const mathJaxMajorVersion = () => (typeof MathJax !== 'undefined' && MathJax.version) ? parseInt(MathJax.version.split('.')[0]) : null;\n\n// Only warn once per page about each of these conditions\nvar warnedMissingMathJax = false;\nvar warnedUnsupportedMathJax = false;\n\n// plotly.js is only compatible with MathJax v3 and v4.\nfunction isMathJaxVersionSupported() {\n    const version = mathJaxMajorVersion();\n    if(version === 3 || version === 4) return true;\n\n    if(version === null) {\n        if(!warnedMissingMathJax) {\n            warnedMissingMathJax = true;\n            Lib.warn('MathJax is not loaded. Math equations will not be rendered.');\n        }\n    } else if(!warnedUnsupportedMathJax) {\n        warnedUnsupportedMathJax = true;\n        Lib.warn('Unsupported MathJax version:', MathJax.version);\n    }\n    return false;\n}\n\nfunction texToSVG(_texString, _config, _callback) {\n    const MathJaxVersion = mathJaxMajorVersion();\n\n    var tmpDiv;\n\n    const initiateMathJax = function() {\n        if(!mathjaxSVGDocument) {\n            const SVG = MathJax._.output.svg_ts.SVG;\n            // fontCache 'local' keeps each rendered svg self-contained\n            const svgConfig = Lib.extendFlat({}, MathJax.config.svg, {fontCache: 'local'});\n            // MathJax v4 enables automatic inline linebreaking by default, which\n            // messes up our layout assumptions. Disabling it gives behavior consistent with v3.\n            if(MathJaxVersion === 4) {\n                svgConfig.linebreaks = Lib.extendFlat({}, svgConfig.linebreaks, {inline: false});","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/plotly/plotly.js/blob/1d090e0b5ffb8d0fdf6e0e4ff51d3f3cf67f1314/src/lib/svg_text_utils.js#L211-L247","documentation":"plotly.js supports MathJax major versions 3 and 4 for rendering TeX to SVG. If MathJax is loaded but its version is neither (e.g. the legacy 2.x), isMathJaxVersionSupported() warns once with 'Unsupported MathJax version:' plus MathJax.version and returns false, leaving equations unrendered.","triggerScenarios":"Page loads MathJax 2.x (e.g. mathjax@2/latest or MathJax.js from the legacy CDN) while plotly.js text contains TeX, or a MathJax beta/other build whose version string does not parse to 3 or 4.","commonSituations":"Upgrading or downgrading MathJax independently of plotly, following older tutorials that reference MathJax 2.x CDN URLs, or vendored MathJax builds pinned to v2.","solutions":["Upgrade to MathJax 3 or 4: <script src=\"https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js\"></script>.","Remove any legacy MathJax 2.x script tags and their config objects (MathJax.Hub.Config).","Port v2 configuration to the v3/v4 window.MathJax = {...} config format.","Re-render the plot after the supported MathJax version loads."],"exampleFix":"<!-- before -->\n<script src=\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.9/MathJax.js\"></script>\n<!-- after -->\n<script src=\"https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js\"></script>","handlingStrategy":"validation","validationCode":"function mathJaxMajorOk() {\n  const v = window.MathJax && window.MathJax.version;\n  const major = v && parseInt(v, 10);\n  return major === 3 || major === 4;\n}","typeGuard":"function isSupportedMathJax(m) { return m != null && [3, 4].includes(parseInt(m.version, 10)); }","tryCatchPattern":"try {\n  if (!mathJaxMajorOk()) throw new Error('MathJax 3/4 required');\n  Plotly.newPlot(gd, data);\n} catch (e) {\n  console.warn(e.message);\n  Plotly.newPlot(gd, data); // plain text fallback\n}","preventionTips":["Pin MathJax to major version 3 or 4 in your dependency/CDN URL.","Remove legacy MathJax 2.x script tags and Hub-based configs.","Check MathJax.version in CI smoke tests for pages that use TeX."],"tags":["mathjax","version-compatibility","latex"],"backgroundTag":"incompatible-library-version","analyzedSha":"1d090e0b5ffb8d0fdf6e0e4ff51d3f3cf67f1314","analyzedAt":"2026-09-02T22:03:39.906Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}