Last active
April 12, 2017 14:51
-
-
Save pkra/b02253d18a7c611fe0ffb4fbd5d6273b to your computer and use it in GitHub Desktop.
cdnjs redirect example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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