Using a local configuration file with the CDN

55 views
Skip to first unread message

serap...@gmail.com

unread,
Feb 22, 2015, 8:08:01 PM2/22/15
to mathja...@googlegroups.com
Hi,

I'm trying to use my own config. file in addition to the default mathjax file, as described here:
http://docs.mathjax.org/en/latest/configuration.html#local-config-files

In the <head> section I used to have a <script type="text/x-mathjax-config" > that contained a few lines of customizations. Now I'm trying to move this to a separate file, say local.js, whose path relative to my current html file is ../js/local.js
so that I now have
<script type="text/javascript"
   src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML,../js/local.js">
</script>
in the <head> section.

However, typsetting does no longer occur, and I'm guessing this is due to what's mentioned in the documentation:

"Note that you also have to edit the loadComplete() call that is at the bottom of the configuration file to change it from [MathJax]/config/local/local.js to the complete URL as you give it in the config parameter."

Now how exactly should I make that modification? Is the "configuration file" referred to here the one of the CDN server (though I would think it's local.js)? Am I then supposed to download it to my own server and make the change? Doesn't that defeat the purpose of loading it from the mathjax servers directly?

In other words, where am I supposed to copy that piece of code?
MathJax.Ajax.loadComplete("../js/local.js");

I think I'm just confused but any help would be much appreciated. Thanks.

Peter Krautzberger

unread,
Feb 24, 2015, 3:59:57 PM2/24/15
to mathja...@googlegroups.com
Hi,

It should go at the bottom of your local.js. However, I suspect you're running into browser security preventing MathJax from accessing your file system.

I would try to use the newer method for inline configurations which allows you to use plain JavaScript, cf. the end of the section http://docs.mathjax.org/en/latest/configuration.html#using-in-line-configuration-options 

That way you can simply load a plain JS file before the script calling MathJax from the CDN.

Regards,
Peter.

--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

serap...@gmail.com

unread,
Feb 24, 2015, 7:22:56 PM2/24/15
to mathja...@googlegroups.com
Hi Peter,

I did try to put it at the end of the file actually, but it seems to get stuck at "Processing math: 100%" regardless, after which nothing happens.
It might be due to a security issue, though I would think I'd get some kind of notification in the console if that were the case.

I used to resort to inline configurations but instead I wanted to have it all in a single file to avoid repetition. Anyways I found a workaround so that should no longer be an issue in my case. Thanks.

PS: Keep up the great work at MathJax, you guys rock.

Davide P. Cervone

unread,
Feb 25, 2015, 8:06:42 AM2/25/15
to mathja...@googlegroups.com
> I did try to put it at the end of the file actually, but it seems to get stuck at "Processing math: 100%" regardless, after which nothing happens.

If you get the processing messages, that means your configuration file has been loaded, so you seem to have gotten the loadComplete() call worked out.

There may be a problem with your configuration itself, not the mechanism for loading it. Perhaps you can provide the actual configuration you are using?

> I used to resort to inline configurations but instead I wanted to have it all in a single file to avoid repetition.

You can do the type of configuration that Peter suggests in a separate file as well. Just use

<script src="my-config-file.js"></script>
<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>

where my-confi-file.js contains

MathJax = {
... your configuration parameters here ...
};

That should do it.

Davide
Reply all
Reply to author
Forward
0 new messages