Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • M MathJax
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 304
    • Issues 304
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 15
    • Merge requests 15
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • MathJax
  • MathJax
  • Issues
  • #2307
Closed
Open
Issue created Jan 25, 2020 by Administrator@rootContributor

MathJax.startup.promise timing issue

Created by: holgerengels

Hi .. I have a problem loading mathjax in a webapp.

I am using the following code to load mathjax in my index.html:

  <script>
      function loadScript(url) {
        return new Promise(function(resolve, reject) {
          const script = document.createElement('script');
          script.type = "text/javascript";
          script.async = true;
          script.src = url;

          script.onload = resolve;
          script.onerror = reject;
          document.head.appendChild(script);
        })
      }

      window.MathJax = { loader: {load: ['input/asciimath', 'output/svg']} };

      window.MathJaxLoader = loadScript("https://cdn.jsdelivr.net/npm/mathjax@3/es5/startup.js")
        .then(() => console.log("loaded"))
        .then(() => window.MathJax.startup.promise)
        .then(() => console.log("initialized"))
        .then(() => console.log(window.MathJax.asciimath2svg))
      ;
  </script>

In chrome's console, I see the output ..

loaded
initialized
undefined

Shouldn't window.MathJax.asciimath2svg be defined when the startup.promise has resolved?

Assignee
Assign to
Time tracking