Skip to content
Peter Krautzberger edited this page Jun 25, 2014 · 2 revisions

A MathJax Q&A -- CDN or not to CDN, that is the question

  • Is it faster if I host a copy of MathJax on my own?

    • For the majority, this is unlikely. The MathJax CDN is provided through a combination of Google Cloud Storage and CloudFlare. It's unlikely you will be using a significantly better CDN in both speed and reliability.
    • In addition, your visitors will not receive the benefits of browser caching across CDN users. Once a visitor has visited a site using the MathJax CDN, the components downloaded dynamically (input/output components, extensions, webfonts etc) will remain in the visitor's browser cache. If the same visitor visits another site using the CDN, these components will not have to be downloaded again. For security reasons, browsers do not allow this re-use across domains, so hosting your own copy of MathJax will mean visitors will only get the benefit of caching if they have visited your site before.
  • Isn't there a risk that the MathJax CDN is down?

    • Since we launched the CDN in 2011, it experienced only two disruptions. The first outage lasted 4h; we documented the background and removed the point of failure by switching the CDN setup. The second outage was a 15 min downtime in 2013 when our DNS provider (godaddy) failed globally -- a rare and extreme event by all standards.
  • Isn't it safer to use my own copy?

    • Besides optional https access, the MathJax CDN is actively maintained by our team and critical bug fixes will be pushed to the CDN immediately. This means it's easier and safer to use our CDN. In addition, the /latest branch will be updated to each new version upon release (after an announcement on our website to give the opportunity to switch to older versions should anybody want to).
  • Does the CDN restrict my ability to configure and extend MathJax?

    • No. MathJax is designed with modularity and flexibility in mind. When using the CDN a content host is still able to configure it anyway they like, including loading additional configuration files together with those from the CDN and loading third-party extensions that are not available in the CDN. The only thing you can't do is modify/hack the original MathJax code that are on the CDN -- but we would strongly advise not to do this anyway, and rather use MathJax's methods to modify core code via the configuration.
  • Is there any scenario where I should host a copy myself?

    • If you use MathJax in restricted networks (intranets, education) or offline (apps), then you probably want your own copy of MathJax. It can also make sense to provide your own MathJax copy as a fallback: given the nature of the net, there's always a chance that a visitor might have temporary connection problems to our CDN due to unstable network connections or some kind of network blocking. MathJax is resilient to temporary connection loss once MathJax.js is loaded, but there's nothing MathJax can do if it isn't loaded. A short line of javascript can check if the visitor has been able to get the initial MathJax script from the CDN, and, if not, fall back to your own copy.
Clone this wiki locally