Search code examples
requirejsmathjax

MathJax with RequireJS, how to set config


Usually, I can include MathJax in a script tag like:

<script src="path-to-MathJax/MathJax.js?config=default"></script>

But with RequireJS, I can include the config, but what happens to the config?


Solution

  • The requirejs documentation on github mentions that you can gain fine-grained control on the URL, by overriding the requirejs load function: https://github.com/jrburke/requirejs/wiki/Fine-grained-URL-control

    <script src="require.js"></script>
    <script>
    (function () {
      var load = requirejs.load;
      requirejs.load = function (context, moduleId, url) {
        //modify url here, then call original load
        return load(context, moduleId, url);
      };
    
      //Now load code.
      require(['main']);
    }());
    </script>