Skip to content

Instantly share code, notes, and snippets.

@pkra
Last active Apr 12, 2017
Embed
What would you like to do?
cdnjs redirect example
(function () {
var newMathJax = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js';
var oldMathJax = 'https://path.to/MathJax.j';
var n = oldMathJax.length;
var scripts = document.getElementsByTagName('script');
for (var i = 0; i < scripts.length; i++) {
var script = scripts[i];
var src = script.getAttribute('src') || '';
if (src.substr(0, n) === oldMathJax) {
var newScript = document.createElement('script');
newScript.src = newMathJax + src.substr(n);
script.parentNode.replaceChild(newScript, script);
console.warn('WARNING: cdn.mathjax.org has been retired. Check https://www.mathjax.org/cdn-shutting-down/ for migration tips.')
break;
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment