{"id":1125,"date":"2017-04-12T08:35:19","date_gmt":"2017-04-12T08:35:19","guid":{"rendered":"http:\/\/www.numbas.org.uk\/?p=1125"},"modified":"2017-04-12T08:56:13","modified_gmt":"2017-04-12T08:56:13","slug":"important-how-the-shutdown-of-cdn-mathjax-org-affects-numbas","status":"publish","type":"post","link":"https:\/\/www.numbas.org.uk\/theme-testing\/blog\/2017\/04\/important-how-the-shutdown-of-cdn-mathjax-org-affects-numbas\/","title":{"rendered":"Important: how the shutdown of cdn.mathjax.org affects Numbas"},"content":{"rendered":"<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1130\" src=\"http:\/\/www.numbas.org.uk\/wp-content\/uploads\/2017\/04\/Keep-calm-and-carry-on-scan.jpg\" alt=\"\" width=\"300\" height=\"449\" srcset=\"https:\/\/www.numbas.org.uk\/wp-content\/uploads\/2017\/04\/Keep-calm-and-carry-on-scan.jpg 300w, https:\/\/www.numbas.org.uk\/wp-content\/uploads\/2017\/04\/Keep-calm-and-carry-on-scan-200x300.jpg 200w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>The MathJax team has <a href=\"https:\/\/www.mathjax.org\/cdn-shutting-down\/\">announced<\/a> that their free cdn.mathjax.org service, which\u00a0serves copies of MathJax, will shut down on April 30, 2017 &#8211; the end of this month. Numbas uses MathJax to render mathematical notation using LaTeX, and until now the default theme has used cdn.mathjax.org.<\/p>\n<p>This is much less notice than we would&#8217;ve liked, but it&#8217;s out of our hands. So we need to change how Numbas uses MathJax from now on, and the shutdown has ramifications for existing exam packages.<\/p>\n<h3>How Numbas will use MathJax from now on<\/h3>\n<p><strong>In short: <\/strong>there&#8217;s a new default URL, and you shouldn&#8217;t notice any difference. You can\u00a0configure Numbas to use your own copy of MathJax if you&#8217;d prefer.<\/p>\n<p><!--more--><\/p>\n<ul>\n<li>By default, MathJax is now loaded from <a href=\"https:\/\/cdnjs.com\/libraries\/mathjax\">cdnjs.org<\/a>, another free CDN (content delivery network) service. Again, this is a free service, so could shut down or change at some point in the future. I\u00a0couldn&#8217;t find a terms of use policy, so there&#8217;s no guarantee of advance warning if that does happen. If this becomes unusable in the future, we&#8217;ll try to find another solution. However, cdnjs is <a href=\"https:\/\/cdnjs.com\/about\">backed by several well-established sponsors and used on over a million websites<\/a>.<\/li>\n<li>You can now set a preferred URL to load MathJax from in <a href=\"https:\/\/numbas.mathcentre.ac.uk\/accounts\/profile\/edit\">your profile on the Numbas editor<\/a>. If your\u00a0institution has a local copy of MathJax, you can use that: any exam or question you compile will use your preferred MathJax URL.<\/li>\n<li>If you run your own instance of the Numbas editor, you must add a <code>MATHJAX_URL<\/code> setting to <code>numbas\/settings.py<\/code>. This should be the URL of the directory containing MathJax.js, for example for cdnjs.org it&#8217;s <code>https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/mathjax\/2.7.0<\/code>.<\/li>\n<\/ul>\n<p>If you&#8217;d like to set up your own copy of MathJax, the MathJax documentation has <a href=\"http:\/\/docs.mathjax.org\/en\/latest\/installation.html\">instructions on installation<\/a>.<\/p>\n<h3>Existing exams<\/h3>\n<p><strong>In short:<\/strong> existing Numbas packages downloaded before April 5th\u00a0<strong>will stop working<\/strong> in 3-6 months&#8217; time. They must be replaced, either by re-downloading from the editor, or modifying the index.html file in each package.<\/p>\n<p>If you\u00a0downloaded a Numbas exam before the\u00a0April 5th, it loads MathJax from cdn.mathjax.org. In the long term, these exams will have to be recompiled and replaced. However, the MathJax team have set cdn.mathjax.org to redirect to cdnjs.org, and expect that to continue for 3-6 months, so any exams uploaded to VLEs should continue working unmodified until the end of the (northern hemisphere) academic year. We can expect a similar amount of warning before this redirection ends.<\/p>\n<p>You should make sure to replace any exams which will be permanently available.\u00a0<strong>You don&#8217;t need to make any changes in the editor<\/strong>: just download the SCORM package or standalone .zip, as before, and the package you get will load MathJax from the new URL.<\/p>\n<p>In case you&#8217;re not able to recompile exams, for whatever reason, or you&#8217;re the kind of person who finds command-line file modification easier, you can update your existing exams by\u00a0making the following change in each exam&#8217;s index.html file:<\/p>\n<p>Replace<\/p>\n<pre>&lt;script type=\"text\/javascript\" src=\"https:\/\/cdn.mathjax.org\/mathjax\/latest\/MathJax.js?config=TeX-AMS-MML_HTMLorMML.js\"&gt;&lt;\/script&gt;<\/pre>\n<p>with<\/p>\n<pre>&lt;script type=\"text\/javascript\" src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/mathjax\/2.7.0\/MathJax.js?config=TeX-AMS-MML_HTMLorMML.js\"&gt;&lt;\/script&gt;<\/pre>\n<p>If your exams are on a server running Linux, we&#8217;ve had some success with the following command, which finds all files containing references to cdn.mathjax.org and replaces them with the cdnjs.org URL. Note that this script modifies files in-place without backups and should be used <strong>entirely at your own risk<\/strong>.<\/p>\n<pre>grep cdn.mathjax.org -rl . | xargs sed -i 's#\\(https\\?:\\)\\?\/\/cdn.mathjax.org\/mathjax\/\\(.*-\\)\\?latest\/#https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/mathjax\/2.7.0\/#g'<\/pre>\n<h3>Other things we&#8217;re doing to help<\/h3>\n<p>An absolutely fail-safe solution would be to include a copy of MathJax with each exam. Unfortunately, MathJax is 33MB, while a typical Numbas exam is only around 1MB. So, I&#8217;m looking into whether it would be possible to create a drastically stripped-down version of MathJax, which could be included with every Numbas exam and used in case the full version can&#8217;t be loaded. I&#8217;m about to go on annual leave for a week, so I expect to\u00a0know whether this is possible in about a fortnight.<\/p>\n<p>Another option we&#8217;re considering is to make a browser extension which automatically replaces any cdn.mathjax.org reference in pages you visit with the corresponding cdnjs.org address. This would work for Chrome and Firefox only, and might be useful if you have exams in use which\u00a0you can&#8217;t replace or modify. This will be quite a bit of work, so I&#8217;ll only investigate this if there&#8217;s sufficient interest &#8211; please <a href=\"mailto:numbas@ncl.ac.uk\">let us know<\/a> if you&#8217;d find this useful.<\/p>\n<h3>In conclusion<\/h3>\n<ul>\n<li>We&#8217;ve made the necessary changes to make sure things keep working.<\/li>\n<li>Try to replace any exams you&#8217;re currently using with students. If you can&#8217;t do that,\u00a0<strong>don&#8217;t worry<\/strong>: they&#8217;ll keep working at least until the end of July.<\/li>\n<li>If you have any queries or encounter problems, <a href=\"mailto:numbas@ncl.ac.uk\">email us<\/a>\u00a0&#8211; we&#8217;ll be happy to help.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>The MathJax team has announced that their free cdn.mathjax.org service, which\u00a0serves copies of MathJax, will shut down on April 30, 2017 &#8211; the end of this month. Numbas uses MathJax to render mathematical notation using LaTeX, and until now the default theme has used cdn.mathjax.org. This is much less notice than we would&#8217;ve liked, but [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[22],"tags":[34],"_links":{"self":[{"href":"https:\/\/www.numbas.org.uk\/theme-testing\/wp-json\/wp\/v2\/posts\/1125"}],"collection":[{"href":"https:\/\/www.numbas.org.uk\/theme-testing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.numbas.org.uk\/theme-testing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.numbas.org.uk\/theme-testing\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.numbas.org.uk\/theme-testing\/wp-json\/wp\/v2\/comments?post=1125"}],"version-history":[{"count":10,"href":"https:\/\/www.numbas.org.uk\/theme-testing\/wp-json\/wp\/v2\/posts\/1125\/revisions"}],"predecessor-version":[{"id":1136,"href":"https:\/\/www.numbas.org.uk\/theme-testing\/wp-json\/wp\/v2\/posts\/1125\/revisions\/1136"}],"wp:attachment":[{"href":"https:\/\/www.numbas.org.uk\/theme-testing\/wp-json\/wp\/v2\/media?parent=1125"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.numbas.org.uk\/theme-testing\/wp-json\/wp\/v2\/categories?post=1125"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.numbas.org.uk\/theme-testing\/wp-json\/wp\/v2\/tags?post=1125"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}