{"record":{"id":"cfbf6bab32e157ae","repo":"plotly/plotly.js","slug":"mathjax-is-not-loaded-math-equations-will-not-be","errorCode":null,"errorMessage":"MathJax is not loaded. Math equations will not be rendered.","messagePattern":"MathJax is not loaded\\. Math equations will not be rendered\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/lib/svg_text_utils.js","lineNumber":225,"sourceCode":"var mathjaxSVGDocument = null;\n\n// Function which returns the major version of MathJax as an integer,\n// or null if MathJax is undefined or MathJax.version is falsy.\nconst 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'});","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/plotly/plotly.js/blob/1d090e0b5ffb8d0fdf6e0e4ff51d3f3cf67f1314/src/lib/svg_text_utils.js#L207-L243","documentation":"When plotly.js renders TeX math (text with $...$ and MathJax enabled in layout), it requires the MathJax library to be loaded in the page. If `window.MathJax` is absent, isMathJaxVersionSupported() warns once that equations will not be rendered and returns false, so the text is shown as raw TeX.","triggerScenarios":"Plotting text containing $...$ or \\(...\\) with layout.tex or MathJax config enabled while the MathJax script tag is missing, loads after plotly, or is loaded asynchronously after the first render.","commonSituations":"Forgetting the <script> tag for MathJax, loading MathJax with `defer`/`async` and calling Plotly.newPlot before it finishes, SPA routing removing the script, or CSP blocking the CDN.","solutions":["Include MathJax v3/v4 in the page before rendering: <script src=\"https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js\"></script>.","If loading asynchronously, wait for MathJax readiness (MathJax.startup.promise or the startup page-ready promise) before Plotly.newPlot.","Re-render / call Plotly.Plots.resize or re-plot once MathJax is available.","If math is not needed, remove $...$ markers or disable the math typesetting config to silence the warning."],"exampleFix":"// before\nPlotly.newPlot(gd, data); // MathJax not yet loaded\n// after\nawait MathJax.startup.promise;\nPlotly.newPlot(gd, data);","handlingStrategy":"fallback","validationCode":"function ensureMathJax() {\n  if (typeof window.MathJax === 'undefined') {\n    const s = document.createElement('script');\n    s.src = 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js';\n    document.head.appendChild(s);\n  }\n}","typeGuard":"function isMathJaxLoaded() { return typeof window !== 'undefined' && typeof window.MathJax !== 'undefined'; }","tryCatchPattern":"try {\n  if (!isMathJaxLoaded()) await loadMathJax();\n  Plotly.newPlot(gd, data);\n} catch (e) {\n  console.warn('Math unavailable, rendering plain text', e);\n  Plotly.newPlot(gd, stripTeX(data));\n}","preventionTips":["Always include the MathJax v3+ script tag before any Plotly.newPlot call.","Wait for MathJax.startup.promise in async apps before first render.","Strip $...$ markers when math rendering is not required."],"tags":["mathjax","missing-dependency","latex"],"backgroundTag":"missing-dependency-mathjax","analyzedSha":"1d090e0b5ffb8d0fdf6e0e4ff51d3f3cf67f1314","analyzedAt":"2026-09-02T22:03:39.906Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}